java.util.Date from LocalDate In UTC - Java java.time

Java examples for java.time:UTC

Description

java.util.Date from LocalDate In UTC

Demo Code


//package com.java2s;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Date;

public class Main {
    private static final ZoneId UTC = ZoneId.of("Z");

    public static Date fromLocalDateInUTC(LocalDate date) {
        return Date.from(date.atStartOfDay().toInstant(ZoneOffset.UTC));
    }//from  w w w. j ava  2  s  .  co m
}

Related Tutorials