@Test void shouldTruncateOffsetSeconds() { OffsetTime time = OffsetTime.of( 14, 55, 50, 0, ZoneOffset.ofHoursMinutesSeconds( 2, 15, 45 ) ); OffsetTime truncatedTime = TemporalUtil.truncateOffsetToMinutes( time ); assertEquals( OffsetTime.of( 14, 55, 5, 0, ZoneOffset.ofHoursMinutes( 2, 15 ) ), truncatedTime ); }
/** * Obtains an instance of {@code ZoneOffset} using an offset in hours. * * @param hours the time-zone offset in hours, from -18 to +18 * @return the zone-offset, not null * @throws DateTimeException if the offset is not in the required range */ public static ZoneOffset ofHours(int hours) { return ofHoursMinutesSeconds(hours, 0, 0); }
/** * Obtains an instance of {@code ZoneOffset} using an offset in * hours and minutes. * <p> * The sign of the hours and minutes components must match. * Thus, if the hours is negative, the minutes must be negative or zero. * If the hours is zero, the minutes may be positive, negative or zero. * * @param hours the time-zone offset in hours, from -18 to +18 * @param minutes the time-zone offset in minutes, from 0 to ±59, sign matches hours * @return the zone-offset, not null * @throws DateTimeException if the offset is not in the required range */ public static ZoneOffset ofHoursMinutes(int hours, int minutes) { return ofHoursMinutesSeconds(hours, minutes, 0); }
addExtendedEntry(YearMonth.of(2016, 6), "YearMonth", "The following example is a `YearMonth` of \"June 2016\"", Compatibilities.UNTYPED_GRAPHSON.matchToArray()); addExtendedEntry(ZonedDateTime.of(2016, 12, 23, 12, 12, 24, 36, ZoneId.of("GMT+2")), "ZonedDateTime", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray()); addExtendedEntry(ZoneOffset.ofHoursMinutesSeconds(3, 6, 9), "ZoneOffset", "The following example is a `ZoneOffset` of three hours, six minutes, and nine seconds.", Compatibilities.UNTYPED_GRAPHSON.matchToArray());
return ofHoursMinutesSeconds(-hours, -minutes, -seconds); } else { return ofHoursMinutesSeconds(hours, minutes, seconds);