Java Convert Epoch Day to LocalDate

Tags: Java LocalDate Java 8

In this Java core tutorial we learn how to convert number epoch days to a LocalDate object in Java programming language.

How to convert Epoch Days to LocalDate in Java

In Java, we can use the LocalDate.ofEpochDay(long epochDay) method to instantiate a new LocalDate object from a given number of epoch days which is an incrementing count of days where day 0 is 1970-01-01.

In the following Java program we show how to use the ofEpochDay(long epochDay) method to convert an epoch days value to a LocalDate object.

ConvertEpochDayToLocalDateExample1.java

import java.time.LocalDate;

public class ConvertEpochDayToLocalDateExample1 {
    public static void main(String... args) {
        long epochDays = 19184;

        // Convert Epoch Days to LocalDate object
        LocalDate localDate = LocalDate.ofEpochDay(epochDays);

        System.out.println("Epoch Days: " + epochDays);
        System.out.println("LocalDate: " + localDate);
    }
}
The output as below.
Epoch Days: 19184
LocalDate: 2022-07-11

Happy Coding 😊

Java LocalDate by Examples

Java Convert Calendar to LocalDate

Java Convert LocalDate to String

Java Convert LocalDate to LocalDateTime

Java Convert LocalDate to OffsetDateTime

Java Convert LocalDate to Epoch Day

Java Convert LocalDate to ZonedDateTime

Java Convert LocalDate to Date

Java Convert Date to LocalDate

Java Convert LocalDate to Calendar