Get date without using Calendar class

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

Get date without using Calendar class
[Java] Get the date 10 days later with the Calendar class
[Java] Get date information 10 days later using milliseconds in the Date class
[Java] Get the date with the LocalDateTime class
Date () and Calendar ()
[Java] How to use Calendar class and Date class
Use of Date class
Test field-injected class in Spring boot test without using Spring container
Output of the day of the week using Ruby's Date class
Why the get method is needed in the Calendar class
When using the constructor of Java's Date class, the date advances by 1900.
[Ruby] Display today's day of the week using Date class
Creating a calendar using Ruby
Example of using abstract class
Get Twitter images using twitter4j
(Spring-data-jpa) How to get POJO (other than entity class) using JPA2.1