Java LocalDate to Date convertToDate(LocalDate localDate)

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

Description

convert To Date

License

Creative Commons License

Parameter

Parameter Description
localDate the LocalDate to convert

Return

a version of the specified

Declaration

static Date convertToDate(LocalDate localDate) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

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

import java.util.Date;

public class Main {
    /**/* ww  w . j a va  2  s  . c  om*/
     * @param localDate
     *            the {@link LocalDate} to convert
     * @return a {@link Date} version of the specified {@link LocalDate}
     */
    static Date convertToDate(LocalDate localDate) {
        /*
         * We use the system TZ here to ensure that the date doesn't shift at all, as
         * FHIR will just use this as an unzoned Date (I think, and if not, it's almost
         * certainly using the same TZ as this system).
         */
        return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
    }
}

Related

  1. date(LocalDate d, ZoneId zone)
  2. date(LocalDate date)
  3. date(LocalDate date)
  4. date(LocalDate date)