Java LocalDate to Date toUtilDate(LocalDate localDate)

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

Description

to Util Date

License

Apache License

Declaration

public static Date toUtilDate(LocalDate localDate) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

import java.util.Date;

public class Main {
    public static Date toUtilDate(LocalDate localDate) {
        if (localDate == null) {
            return null;
        }//from   w w  w. ja va  2s .c o m
        return toUtilDate(localDate.atTime(0, 0, 0, 0));
    }

    public static Date toUtilDate(LocalDateTime localDateTime) {
        if (localDateTime == null) {
            return null;
        }
        final ZoneId systemDefault = ZoneId.systemDefault();
        return Date.from(localDateTime.toInstant(systemDefault.getRules().getOffset(localDateTime)));
    }
}

Related

  1. toDate(LocalDate localDate)
  2. toDate(LocalDate localDate)
  3. toDate(LocalDate localDate)
  4. toDate(LocalDate localDate)
  5. toDate(LocalDate localDate)