/** * Returns true if both datetime are in the same year and month, false otherwise. * * @param actual the actual datetime. expected not be null * @param other the other datetime. expected not be null * @return true if both datetime are in the same year and month, false otherwise */ private static boolean haveSameYearAndMonth(ZonedDateTime actual, ZonedDateTime other) { return haveSameYear(actual, other) && actual.getMonth() == other.getMonth(); }
/** * Returns true if both datetime are in the same year and month, false otherwise. * * @param actual the actual datetime. expected not be null * @param other the other datetime. expected not be null * @return true if both datetime are in the same year and month, false otherwise */ private static boolean haveSameYearAndMonth(ZonedDateTime actual, ZonedDateTime other) { return haveSameYear(actual, other) && actual.getMonth() == other.getMonth(); }
public Month getMonth() { return dt.getMonth(); }
private void assertTimestamp(String c4) { // '2014-09-08 17:51:04.777' // MySQL container is in UTC and the test time is during summer time period ZonedDateTime expectedTimestamp = ZonedDateTime.ofInstant( LocalDateTime.parse("2014-09-08T17:51:04.780").atZone(ZoneId.of("US/Samoa")).toInstant(), ZoneId.systemDefault()); ZoneId defaultZoneId = ZoneId.systemDefault(); ZonedDateTime c4DateTime = ZonedDateTime.parse(c4, ZonedTimestamp.FORMATTER).withZoneSameInstant(defaultZoneId); assertThat(c4DateTime.getYear()).isEqualTo(expectedTimestamp.getYear()); assertThat(c4DateTime.getMonth()).isEqualTo(expectedTimestamp.getMonth()); assertThat(c4DateTime.getDayOfMonth()).isEqualTo(expectedTimestamp.getDayOfMonth()); assertThat(c4DateTime.getHour()).isEqualTo(expectedTimestamp.getHour()); assertThat(c4DateTime.getMinute()).isEqualTo(expectedTimestamp.getMinute()); assertThat(c4DateTime.getSecond()).isEqualTo(expectedTimestamp.getSecond()); assertThat(c4DateTime.getNano()).isEqualTo(expectedTimestamp.getNano()); // We're running the connector in the same timezone as the server, so the timezone in the timestamp // should match our current offset ... LocalDateTime expectedLocalDateTime = LocalDateTime.parse("2014-09-08T17:51:04.780"); ZoneOffset expectedOffset = defaultZoneId.getRules().getOffset(expectedLocalDateTime); assertThat(c4DateTime.getOffset()).isEqualTo(expectedOffset); }
String month = dateTime.getMonth().getDisplayName(SHORT, US); int day = dateTime.getDayOfMonth(); String weekDay = dateTime.getDayOfWeek().getDisplayName(SHORT, US);
@Override protected Object invokeZonedDateTime(VertexiumCypherQueryContext ctx, ZonedDateTime date, ExpressionScope scope) { return date.getMonth(); } }
/** * Returns true if both datetime are in the same year and month, false otherwise. * * @param actual the actual datetime. expected not be null * @param other the other datetime. expected not be null * @return true if both datetime are in the same year and month, false otherwise */ private static boolean haveSameYearAndMonth(ZonedDateTime actual, ZonedDateTime other) { return haveSameYear(actual, other) && actual.getMonth() == other.getMonth(); }
public Double month(ZonedDateTime dateTime) { try { return Double.valueOf(dateTime.getMonth().getValue()); } catch (Exception e) { String message = String.format("month(%s)", dateTime); logError(message, e); return null; } }
public BigDecimal month(ZonedDateTime dateTime) { try { return BigDecimal.valueOf(dateTime.getMonth().getValue()); } catch (Exception e) { String message = String.format("month(%s)", dateTime); logError(message, e); return null; } }
public BigDecimal month(ZonedDateTime dateTime) { try { return BigDecimal.valueOf(dateTime.getMonth().getValue()); } catch (Exception e) { String message = String.format("month(%s)", dateTime); logError(message, e); return null; } }
public Double month(ZonedDateTime dateTime) { try { return Double.valueOf(dateTime.getMonth().getValue()); } catch (Exception e) { String message = String.format("month(%s)", dateTime); logError(message, e); return null; } }
public BigDecimal month(ZonedDateTime dateTime) { try { return BigDecimal.valueOf(dateTime.getMonth().getValue()); } catch (Exception e) { String message = String.format("month(%s)", dateTime); logError(message, e); return null; } }
@Override public YearMonth convert(Date in, Context context) throws Exception { if (in == null) return null; ZonedDateTime zonedDateTime = in.toInstant().atZone(zoneId); return YearMonth.of(zonedDateTime.getYear(), zonedDateTime.getMonth()); } }
public Duration getMeetingDurationInMonth(Month month) { return meetings.values().stream() .filter(m -> month.equals(m.getStart().getMonth())) .map(m -> Duration.between(m.getStart(), m.getEnd())) .reduce(Duration.ofMinutes(0), (a, b) -> a.plus(b)); }
ZoneId zoneId = ZoneId.of( "America/Montreal" ); // Or 'ZoneOffset.UTC'. ZonedDateTime now = ZonedDateTime.now( zoneId ); Month month = now.getMonth(); int monthNumber = month.getValue(); // Answer to the Question. String monthName = month.getDisplayName( TextStyle.FULL , Locale.CANADA_FRENCH );
/** * Creates LocalDateTime based on seconds from midnight for time and date from requested ZonedDateTime * * @param time in seconds from midnight * @param fromTimeDateZD * @return */ private ZonedDateTime createTime(int time, ZonedDateTime fromTimeDateZD) { //TODO: check timezones correct time etc. this is untested LocalDateTime localDateTime = LocalDateTime.of(fromTimeDateZD.getYear(), fromTimeDateZD.getMonth(), fromTimeDateZD.getDayOfMonth(), 0,0); return localDateTime.plusSeconds(time).atZone(fromTimeDateZD.getZone()); }
/** * Creates LocalDateTime based on seconds from midnight for time and date from requested ZonedDateTime * * @param time in seconds from midnight * @param fromTimeDateZD * @return */ private ZonedDateTime createTime(int time, ZonedDateTime fromTimeDateZD) { //TODO: check timezones correct time etc. this is untested LocalDateTime localDateTime = LocalDateTime.of(fromTimeDateZD.getYear(), fromTimeDateZD.getMonth(), fromTimeDateZD.getDayOfMonth(), 0,0); return localDateTime.plusSeconds(time).atZone(fromTimeDateZD.getZone()); }
private ZonedDateTime toEndOfPreviousMonth(final ZonedDateTime datetime) { final ZonedDateTime previousMonth = datetime.minusMonths(1).with(lastDayOfMonth()); final int highestHour = hours.getValues().get(hours.getValues().size() - 1); final int highestMinute = minutes.getValues().get(minutes.getValues().size() - 1); final int highestSecond = seconds.getValues().get(seconds.getValues().size() - 1); return ZonedDateTime .of(previousMonth.getYear(), previousMonth.getMonth().getValue(), previousMonth.getDayOfMonth(), highestHour, highestMinute, highestSecond, 0, previousMonth.getZone()); }
@Test void monthOfYearShouldBeParsed() { ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()); assertThat(dateTime.getMonth()).isEqualTo(Month.JUNE); }
@Test public void monthOfYearShouldBeParsed() { ZonedDateTime dateTime = ZonedDateTime.parse("Wed, 28 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()); assertThat(dateTime.getMonth()).isEqualTo(Month.JUNE); }