Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert LocalDateTime to Date

Tags:

java

I have a string date, and I convert it with statement below:

LocalDateTime datetime = LocalDateTime.parse(rs.getString("DateIn"), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));

Now I want to convert datetime into Date for comparison purpose, how to convert it?

like image 803
Newbie Avatar asked Jan 06 '23 09:01

Newbie


1 Answers

Date convertedDatetime = Date.from(datetime.atZone(ZoneId.systemDefault()).toInstant());
like image 75
Matteo Baldi Avatar answered Jan 20 '23 18:01

Matteo Baldi