jdk/src/java.base/share/classes/java/time/LocalTime.java
changeset 34828 bc3eacb42ab1
parent 34388 ab5f741f776a
child 37880 60ec48925dc6
equal deleted inserted replaced
34827:de746e7eb1e3 34828:bc3eacb42ab1
  1488         total += second * NANOS_PER_SECOND;
  1488         total += second * NANOS_PER_SECOND;
  1489         total += nano;
  1489         total += nano;
  1490         return total;
  1490         return total;
  1491     }
  1491     }
  1492 
  1492 
       
  1493     /**
       
  1494      * Converts this {@code LocalTime} to the number of seconds since the epoch
       
  1495      * of 1970-01-01T00:00:00Z.
       
  1496      * <p>
       
  1497      * This combines this local time with the specified date and
       
  1498      * offset to calculate the epoch-second value, which is the
       
  1499      * number of elapsed seconds from 1970-01-01T00:00:00Z.
       
  1500      * Instants on the time-line after the epoch are positive, earlier
       
  1501      * are negative.
       
  1502      *
       
  1503      * @param date the local date, not null
       
  1504      * @param offset the zone offset, not null
       
  1505      * @return the number of seconds since the epoch of 1970-01-01T00:00:00Z, may be negative
       
  1506      * @since 9
       
  1507      */
       
  1508     public long toEpochSecond(LocalDate date, ZoneOffset offset) {
       
  1509         Objects.requireNonNull(date, "date");
       
  1510         Objects.requireNonNull(offset, "offset");
       
  1511         long epochDay = date.toEpochDay();
       
  1512         long secs = epochDay * 86400 + toSecondOfDay();
       
  1513         secs -= offset.getTotalSeconds();
       
  1514         return secs;
       
  1515     }
       
  1516 
  1493     //-----------------------------------------------------------------------
  1517     //-----------------------------------------------------------------------
  1494     /**
  1518     /**
  1495      * Compares this time to another time.
  1519      * Compares this time to another time.
  1496      * <p>
  1520      * <p>
  1497      * The comparison is based on the time-line position of the local times within a day.
  1521      * The comparison is based on the time-line position of the local times within a day.