Java LocalDate to Date date(LocalDate date)

Here you can find the source of date(LocalDate date)

Description

date

License

Open Source License

Return

passed in local date converted to date using the default clock

Declaration

public static Date date(LocalDate date) 

Method Source Code


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

import java.time.Clock;
import java.time.LocalDate;
import java.time.LocalDateTime;

import java.util.Date;

public class Main {
    private static final Clock DEFAULT_CLOCK = Clock.systemUTC();

    /**/*from ww  w . ja v a 2s. com*/
     * @return passed in local date time converted to date using the provided clock
     */
    public static Date date(LocalDateTime date, Clock clock) {
        return Date.from(date.atZone(clock.getZone()).toInstant());
    }

    /**
     * @return passed in local date time converted to date using the default clock
     */
    public static Date date(LocalDateTime date) {
        return date(date, DEFAULT_CLOCK);
    }

    /**
     * @return passed in local date converted to date using the provided clock
     */
    public static Date date(LocalDate date, Clock clock) {
        return Date.from(date.atStartOfDay().atZone(clock.getZone()).toInstant());
    }

    /**
     * @return passed in local date converted to date using the default clock
     */
    public static Date date(LocalDate date) {
        return date(date, DEFAULT_CLOCK);
    }
}

Related

  1. convertToDate(LocalDate localDate)
  2. date(LocalDate d, ZoneId zone)
  3. date(LocalDate date)
  4. date(LocalDate date)
  5. localDateToDate(LocalDate date)
  6. localDateToDate(LocalDate ld)
  7. toDate(final LocalDate localDate)
  8. toDate(LocalDate date)