Java Data Type How to - Convert java.util.Date to LocalDate


We would like to know how to convert java.util.Date to LocalDate.


import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
/*from  w ww.  j  a  v  a  2s  . c om*/
public class Main {

  public static void main(String[] args) {
    System.out.println(fromDate(new Date()));

  public static LocalDate fromDate(Date date) {
    Instant instant = Instant.ofEpochMilli(date.getTime());
    return LocalDateTime.ofInstant(instant, ZoneId.systemDefault())

The code above generates the following result.