Java LocalDateTime to convertLocalDateTimeToDateInUTC(final LocalDateTime ldt)

Here you can find the source of convertLocalDateTimeToDateInUTC(final LocalDateTime ldt)

Description

convert Local Date Time To Date In UTC

License

Open Source License

Declaration

public static Date convertLocalDateTimeToDateInUTC(final LocalDateTime ldt) 

Method Source Code

//package com.java2s;
// ProjectForge is dual-licensed.

import java.time.Instant;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    /**//from   w  w  w. j a v  a2s.com
     * UTC
     */
    public final static TimeZone UTC = TimeZone.getTimeZone("UTC");

    public static Date convertLocalDateTimeToDateInUTC(final LocalDateTime ldt) {
        final Instant instant = ldt.toInstant(ZoneOffset.UTC);
        return Date.from(instant);
    }
}

Related

  1. convertToDate(LocalDateTime dateTime)
  2. fromLocalDateTime(LocalDateTime _ldt)
  3. getDate(LocalDateTime time)
  4. getDateTimeText(LocalDateTime dateTime)