Java: How to get the current date (and time) in Java 8, 11, 14, 17, etc.
Briefly

With Java 8 and newer, use any of the 'now' methods on these Java classes to get the current data and time: LocalDate.now(), LocalTime.now(), LocalDateTime.now(), Instant.now(), ZonedDateTime.now().
If you're interested in the current date, LocalDate.now() is probably what you're looking for. If you need the current time, other methods like LocalTime.now() might be suitable.
Older techniques before Java 8 involved creating Java Date objects using Calendar and java.sql.Date conversions, but it is recommended to use LocalDate.now() with newer Java versions.
Read at Alvinalexander
[
add
]
[
|
|
]