/** * @author lautturi.com * Java example: convert Date to LocalDate in java */ import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.*; public class Lautturi { public static void main(String[] args) { Date today = new Date(); LocalDate ld = Instant.ofEpochMilli(today.getTime()) .atZone(ZoneId.systemDefault()) .toLocalDate(); System.out.println(ld); } }
output:
2020-11-20