< prev index next >

src/java.base/share/classes/java/time/LocalTime.java

Print this page

        

*** 1486,1495 **** --- 1486,1510 ---- total += minute * NANOS_PER_MINUTE; total += second * NANOS_PER_SECOND; total += nano; return total; } + /** + * Converts this {@code LocalTime} to the number of seconds since the epoch + * of 1970-01-01T00:00:00Z. + * <p> + * This returns the number of seconds from the epoch for this {@link LocalTime}. + * + * @param offset the zone offset, not null + * @return the number of seconds since the epoch of 1970-01-01T00:00:00Z, may be negative + */ + public int toEpochSecond(ZoneOffset offset) { + Objects.requireNonNull(offset, "offset"); + int secs = toSecondOfDay(); + secs -= offset.getTotalSeconds(); + return secs; + } //----------------------------------------------------------------------- /** * Compares this time to another time. * <p>
< prev index next >