/** * Returns true if both datetime are in the same year, month, day of month and hour, 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, month, day of month and hour, false otherwise. */ private static boolean areEqualIgnoringMinutes(ZonedDateTime actual, ZonedDateTime other) { return haveSameYearMonthAndDayOfMonth(actual, other) && actual.getHour() == other.getHour(); }
/** * Returns true if both datetime are in the same year, month, day of month and hour, 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, month, day of month and hour, false otherwise. */ private static boolean areEqualIgnoringMinutes(ZonedDateTime actual, ZonedDateTime other) { return haveSameYearMonthAndDayOfMonth(actual, other) && actual.getHour() == other.getHour(); }
ZonedDateTime buildZonedStartAt(ZonedDateTime zonedNow, ZoneId zoneId) { ZonedDateTime zonedStartAt = getZonedFromTs(atTime, zoneId); zonedStartAt = zonedNow .withHour(zonedStartAt.getHour()) .withMinute(zonedStartAt.getMinute()) .withSecond(zonedStartAt.getSecond()); return adjustToStartDate(zonedStartAt, zonedNow, zoneId); }
public int getHour() { return dt.getHour(); }
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); }
@Deprecated public int getHourOfDay() { logDeprecatedMethod("getHourOfDay()", "getHour()"); return dt.getHour(); }
private void assertTimeZoneHour(ZonedDateTime openingDate) { assertEquals(openingDate.getHour(), 15); }
private void assertTimeZoneWithoutSeconds(ZonedDateTime openingDate) { assertEquals(openingDate.getHour(), HOUR); assertEquals(openingDate.getMinute(), MINUTE); }
private void assertTimeZoneDateTime(ZonedDateTime openingDate) { assertEquals(openingDate.getHour(), HOUR); assertEquals(openingDate.getMinute(), MINUTE); assertEquals(openingDate.getSecond(), SECOND); }
Date date = new Date(); // Convert to java 8 ZonedDateTime Date date = new Date(); final ZonedDateTime dateTime = date.toInstant() .atZone(ZoneId.systemDefault()); // Get the hour int hour = dateTime.getHour();
/** * Returns true if both datetime are in the same year, month, day of month and hour, 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, month, day of month and hour, false otherwise. */ private static boolean areEqualIgnoringMinutes(ZonedDateTime actual, ZonedDateTime other) { return haveSameYearMonthAndDayOfMonth(actual, other) && actual.getHour() == other.getHour(); }
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final ZonedDateTime zonedDateTime) { output.writeInt(zonedDateTime.getYear()); output.writeInt(zonedDateTime.getMonthValue()); output.writeInt(zonedDateTime.getDayOfMonth()); output.writeInt(zonedDateTime.getHour()); output.writeInt(zonedDateTime.getMinute()); output.writeInt(zonedDateTime.getSecond()); output.writeInt(zonedDateTime.getNano()); output.writeString(zonedDateTime.getZone().getId()); }
@Deprecated public int getHourOfDay() { logDeprecatedMethod("getHourOfDay()", "getHour()"); return dt.getHour(); }
@Test void hourOfDayShouldBeParsed() { ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 04:35:11 -0700", ImapDateTimeFormatter.rfc5322()); assertThat(dateTime.getHour()).isEqualTo(4); }
@Test void parseShouldNotThrowWhenHourOfDayIsLesserThanTwoDigits() { ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 4:35:11 -0700", ImapDateTimeFormatter.rfc5322()); assertThat(dateTime.getHour()).isEqualTo(4); }
@Test public void parseShouldNotThrowWhenHourOfDayIsLesserThanTwoDigits() { ZonedDateTime dateTime = ZonedDateTime.parse("3 Jun 2017 4:35:11 -0700", ImapDateTimeFormatter.rfc5322()); assertThat(dateTime.getHour()).isEqualTo(4); }
public ZonedDateTime toLastDate(ZonedDateTime date) { YearMonth yearMonth = toYearMonth(date); int lastDayOfMonth = yearMonth.lengthOfMonth(); return (date == null) ? null : ZonedDateTime.of(date.getYear(), date.getMonthValue(), lastDayOfMonth, date.getHour(), date.getMinute(), date.getSecond(), date.getNano(), date.getZone()); }
static Tuple toTuple(ZonedDateTime timestamp) { return Tuple.from( -timestamp.getYear(), -timestamp.getMonth().getValue(), -timestamp.getDayOfMonth(), -timestamp.getHour(), -timestamp.getMinute(), -timestamp.getSecond(), -TimeUnit.NANOSECONDS.toMillis(timestamp.getNano()) ); }
static DateValue zonedDateTimeToDateValue(ZonedDateTime dt) { return new DateTimeValueImpl( dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(), dt.getHour(), dt.getMinute(), dt.getSecond()); }
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final ZonedDateTime zonedDateTime) { output.writeInt(zonedDateTime.getYear()); output.writeInt(zonedDateTime.getMonthValue()); output.writeInt(zonedDateTime.getDayOfMonth()); output.writeInt(zonedDateTime.getHour()); output.writeInt(zonedDateTime.getMinute()); output.writeInt(zonedDateTime.getSecond()); output.writeInt(zonedDateTime.getNano()); output.writeString(zonedDateTime.getZone().getId()); }