Java Date Time - LocalDate toEpochDay() example








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;
//from  w w w.j  a  v  a 2 s .  c  om
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.