java.util.Date as LocalDateTime - Java java.time

Java examples for java.time:LocalDateTime

Description

java.util.Date as LocalDateTime

Demo Code


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

import java.time.LocalDateTime;
import java.time.ZoneId;

import java.util.Date;

public class Main {
    public static LocalDateTime asLocalDateTime(Date date) {
        return Instant.ofEpochMilli(date.getTime())
                .atZone(ZoneId.systemDefault()).toLocalDateTime();
    }//from  w  ww .  ja v a  2  s.  c  om
}

Related Tutorials