convert java date to localdate
javaTo convert a java.util.Date object to a java.time.LocalDate object, you can use the toInstant method of the Date class to get an Instant object, and then use the atZone method of the Instant object to get a ZonedDateTime object. Finally, you can use the toLocalDate method of the ZonedDateTime object to get the LocalDate object.
Here is an example:
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Date date = new Date();
ZonedDateTime zonedDateTime = date.toInstant().atZone(ZoneId.systemDefault());
LocalDate localDate = zonedDateTime.toLocalDate();
System.out.println(localDate);
}
}
This will convert the Date object to a LocalDate object with the same date and the system default time zone.
Other Article on Tag java
- - after and before in java date
- - am pm java date format
- - apk minecraft java edition
- - as been blocked by CORS policy Response to preflight request doesn't pass access control check It does not have HTTP ok status
- - bubble sort in java
- - Can I compile and run a spring boot jar from inside another spring boot application
- - convert java date to localdate
- - design patterns in java
- - encrypt by java and decrypt by node
- - exception handling in java