Java LocalDate to Date toDate(LocalDate localDate)

Here you can find the source of toDate(LocalDate localDate)

Description

to Date

License

Open Source License

Declaration

public static Date toDate(LocalDate localDate) 

Method Source Code

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

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;

import java.time.ZonedDateTime;

import java.util.Date;

public class Main {
    public static final ZoneId DEFAULT_ZONEID = ZoneId.systemDefault();

    public static Date toDate(LocalDateTime dateTime) {
        if (dateTime == null) {
            return null;
        }/* w w  w.  j  a  v  a  2s . co  m*/
        ZonedDateTime zonedDateTime = dateTime.atZone(DEFAULT_ZONEID);
        return Date.from(zonedDateTime.toInstant());
    }

    public static Date toDate(LocalDate localDate) {
        if (localDate == null) {
            return null;
        }
        ZonedDateTime zonedDateTime = localDate.atStartOfDay(DEFAULT_ZONEID);
        return Date.from(zonedDateTime.toInstant());
    }

    public static Date toDate(ZonedDateTime dateTime) {
        if (dateTime == null) {
            return null;
        }
        return Date.from(dateTime.toInstant());
    }
}

Related

  1. toDate(LocalDate ld)
  2. toDate(LocalDate ld)
  3. toDate(LocalDate localDate)
  4. toDate(LocalDate localDate)
  5. toDate(LocalDate localDate)
  6. toDate(LocalDate localDate)
  7. toUtilDate(LocalDate localDate)