LocalDate toEpochDay() example

Description

LocalDate toEpochDay() converts to epoch day.

Syntax

toEpochDay has the following syntax.


public long toEpochDay()

Example

The following example shows how to use toEpochDay.


import java.time.LocalDate;
/* ww  w  .  j  a v  a2 s.c  o m*/
public class Main {
  public static void main(String[] args) {
    LocalDate a = LocalDate.of(2014, 6, 30);
    LocalDate b = LocalDate.of(2014, 7, 1);
    System.out.println(a.toEpochDay()); 
    System.out.println(b.toEpochDay()); 
 
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset