The one that usually comes up when searching for a date
Calendar c = Calendar.getInstance();
Date date2 = c.getTime();
/*
Speaking of which, it's not Calendar, but there are also the following:
Date d = new Date();
*/
The one added in Java 8
//Get the current date and time with Instant
Instant i = Instant.now();
//Get with LocalDateTime
LocalDateTime l = LocalDateTime.now();
There are many other things, but I will omit them. By the way, it seems that you can convert from java.sql.Timestamp type to LocalDateTime type.
Recommended Posts