Java LocalDate to from(LocalDate localDate, LocalTime localTime)

Here you can find the source of from(LocalDate localDate, LocalTime localTime)

Description

from

License

Open Source License

Declaration

public static Date from(LocalDate localDate, LocalTime localTime) 

Method Source Code


//package com.java2s;
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.OffsetDateTime;
import java.util.Date;

public class Main {
    public static Date from(LocalDate localDate, LocalTime localTime) {
        return from(localDate, localTime, ZoneOffset.UTC);
    }//www.j a v a 2s.c  o m

    public static Date from(LocalDate localDate, LocalTime localTime, ZoneOffset zoneOffset) {
        LocalDateTime localDateTime = localDate.atTime(localTime);

        return from(localDateTime, zoneOffset);
    }

    public static Date from(LocalDateTime localDateTime, ZoneOffset zoneOffset) {
        OffsetDateTime zdt = localDateTime.atOffset(zoneOffset);

        return Date.from(zdt.toInstant());
    }
}

Related

  1. from(LocalDate localDate, LocalTime localTime, ZoneOffset zoneOffset)
  2. fromLocalDate(LocalDate date)
  3. fromLocalDate(LocalDate date, TimeZone timeZone)
  4. toBadDate(LocalDate localDate, ZoneId timezone)