Java LocalDate to Date toDate(LocalDate localDate)

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

Description

to Date

License

LGPL

Declaration

public static Date toDate(LocalDate localDate) 

Method Source Code

//package com.java2s;
/*/*  www  . j a  va  2s.c om*/
 * License GNU LGPL
 * Copyright (C) 2012 Amrullah <amrullah@panemu.com>.
 */

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 toDate(LocalDate localDate) {
        if (localDate == null) {
            return null;
        }

        Instant instant = localDate.atStartOfDay()
                .atZone(ZoneId.systemDefault()).toInstant();
        Date date = Date.from(instant);
        return date;
    }

    public static Date toDate(LocalDateTime localDateTime) {
        if (localDateTime == null) {
            return null;
        }

        Instant instant = localDateTime.atZone(ZoneId.systemDefault())
                .toInstant();
        Date date = Date.from(instant);
        return date;
    }
}

Related

  1. toDate(LocalDate date)
  2. toDate(LocalDate finalProjectDate, ZoneId zone)
  3. toDate(LocalDate ld)
  4. toDate(LocalDate ld)
  5. toDate(LocalDate localDate)
  6. toDate(LocalDate localDate)
  7. toDate(LocalDate localDate)
  8. toDate(LocalDate localDate)
  9. toUtilDate(LocalDate localDate)