Java LocalDate Calculate convert(LocalDate ld)

Here you can find the source of convert(LocalDate ld)

Description

convert

License

Open Source License

Declaration

public static Date convert(LocalDate ld) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

public class Main {
    public static Date convert(LocalDate ld) {
        Instant instant = ld.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
        return Date.from(instant);
    }//from   ww  w  . j a v a2 s .  c o m

    public static Date convert(LocalDateTime ldt) {
        Instant instant = ldt.atZone(ZoneId.systemDefault()).toInstant();
        return Date.from(instant);
    }

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

Related

  1. atEndOfDay(LocalDate date)
  2. before(final LocalDate d1, final LocalDate d2)
  3. calcNextDayOfWeek(LocalDate d, DayOfWeek dow)
  4. calculateAge(LocalDate birthDate, LocalDate currentDate)
  5. changeDateToLocalDate(Date value)
  6. convertDatabaseDateToUS(LocalDate databaseDate)
  7. converterToLocalDate(final String date)
  8. convertLocalDateToDatabaseDateString(LocalDate localDate)
  9. dateToSystemLocalDate(Date d)