LocalDateTime to Date - Java java.time

Java examples for java.time:LocalDateTime

Description

LocalDateTime to Date

Demo Code


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

import java.util.Date;

public class Main {
    public static Date toDate(LocalDateTime from) {
        return Date.from(from.atZone(ZoneId.systemDefault()).toInstant());
    }//ww w  .j  av  a  2 s. c  o m
}

Related Tutorials