Mutual conversion between date and localdatetime

Sometimes you want to change the time of localDateTime, but Calendar can only change the information of date. You need to convert date to localDateTime or change localDateTime to date.

//date->localDateTime
Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime()
//localDateTime->date
Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());

Read More: