convert java.util.Date to LocalDateTime - Java java.time

Java examples for java.time:LocalDateTime

Description

convert java.util.Date to LocalDateTime

Demo Code


//package com.java2s;

import java.util.Date;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class Main {
    public static LocalDateTime convertDate(Date date) {
        return date == null ? null : LocalDateTime.ofInstant(
                date.toInstant(), ZoneId.systemDefault());
    }/*from w  w  w  . ja va 2s  .  c  o m*/
}

Related Tutorials