Converts a java.util.Date to java.time.ZonedDateTime. - Java java.time

Java examples for java.time:ZonedDateTime

Description

Converts a java.util.Date to java.time.ZonedDateTime.

Demo Code


//package com.java2s;

import java.time.*;

import java.util.Date;

public class Main {
    /**//  w w  w.  j  a  v a 2 s.  co  m
     * Converts a java.util.Date to java.time.ZonedDateTime.
     *
     * @param date The Date input
     * @return A ZonedDateTime representing the time
     */
    public static ZonedDateTime convertDate(Date date) {
        return date.toInstant().atZone(ZoneId.systemDefault());
    }
}

Related Tutorials