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

Java examples for java.time:UTC

Description

java.util.Date as LocalDate In UTC

Demo Code


//package com.java2s;
import java.time.LocalDate;
import java.time.ZoneId;

import java.util.Date;

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

    public static LocalDate asLocalDateInUTC(Date date) {
        return date.toInstant().atZone(UTC).toLocalDate();
    }//from   w w  w  .  j a v a 2 s .c o  m
}

Related Tutorials