java.util.Date To ZonedDateTime - Java java.time

Java examples for java.time:ZonedDateTime

Description

java.util.Date To ZonedDateTime

Demo Code


//package com.java2s;
import java.time.Instant;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Date;

public class Main {
    public static ZonedDateTime dateToLocalDateTime(Date date) {
        Instant endDateInstant = Instant.ofEpochMilli(date.getTime());
        return ZonedDateTime.ofInstant(endDateInstant, ZoneOffset.UTC);
    }/*from  ww w  .j a  v  a2  s .  co  m*/
}

Related Tutorials