Java Data Type How to - Get list of local dates from a java.util.Date


We would like to know how to get list of local dates from a java.util.Date.


/*from w  w  w  .j a va 2  s  . c o m*/
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Main {
  public static void main(String[] argv) {
    System.out.println(getDatesFrom(new Date(1462312311223L)));

  public static List<LocalDate> getDatesFrom(Date startDate) {
    List<LocalDate> dates = new ArrayList<>();

    LocalDate startLocalDate = getLocalDateFromDate(startDate);

    LocalDate endLocalDate =;

    for (int i = 0; i < ChronoUnit.DAYS.between(startLocalDate, endLocalDate); i++) {
      dates.add(startLocalDate.plusDays(i + 1));

    return dates;

  public static LocalDate getLocalDateFromDate(Date date) {
    return LocalDateTime.ofInstant(new Date(date.getTime()).toInstant(),

The code above generates the following result.