VOOZH about

URL: https://www.geeksforgeeks.org/java/localdate-ofepochday-method-in-java-with-examples/

⇱ LocalDate ofEpochDay() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

LocalDate ofEpochDay() method in Java with Examples

Last Updated : 21 May, 2020
The ofEpochDay(long epochDay) method of LocalDate class in Java is used to obtain an instance of LocalDate from the epoch day count. Epoch day is 01-01-1970(DD-MM-YYYY). This is considered as a start of the epoch day. The method returns the LocalDate by adding the passed days into Epoch date i.e. 01-01-1970. Suppose 2 is passed as a parameter, the method will return 03-01-1970 (2 is added to '01' from the epoch day(DD)). Similarly, if 365 is passed then a whole new year will be added to the epoch date. Syntax:
public static LocalDate ofEpochDay(long epochDay)
Parameters: This method accepts one parameter epochDay which is the conversion base. Return Value: This method returns the localdate after conversion. Exceptions: This method throws DateTimeException if the epoch day exceeds the supported date range. Below programs illustrate the ofEpochDay(long epochDay) method in Java: Program 1:
Output:
Date: 1970-04-11
Program 2:
Comment
Article Tags: