Java Convert Instant to Date
Tags: Java Instant Java Date Java 8
In this Java core tutorial we learn how to convert a java.time.Instant object into a java.util.Date object in Java programming language.
How to convert Instant to Date in Java
In Java, with a given Instant object we can use the Date.from(Instant instant) static method to convert it to a Date object as the example Java code below.
ConvertInstantToDateExample1.java
import java.time.Instant;
import java.util.Date;
public class ConvertInstantToDateExample1 {
public static void main(String... args) {
Instant instant = Instant.now();
Date date = Date.from(instant);
System.out.println("Instant: " + instant);
System.out.println("Date: " + date);
}
}
Instant: 2022-05-17T16:28:43.058074300Z
Date: Tue May 17 23:28:43 ICT 2022
Happy Coding 😊
Related Articles
Java Convert Instant to Calendar
Java Convert Instant to LocalDateTime
Java Convert Instant to LocalDate
Java Convert Instant to LocalTime
Java Convert Instant to ZonedDateTime
Java Convert Instant to OffsetDateTime
Java Convert Instant to Epoch Seconds
Java Convert Instant to Epoch Milliseconds