java new Date code example
Example 1: how to create date class in java
// This creates a new Date instance with current system time. Internally It uses System.currentTimeMillis()
Date date = new Date();
// This creates a new Date instance with time that you specify in milliseconds since the epoch time
Date date = new Date(1672556400000L); // This time is Jan 1 2023 in GMT
Example 2: dates in java 8
LocalDate.of(2015, 02, 20);
LocalDate.parse("2015-02-20");
Example 3: dates in java 8
LocalTime sixThirty = LocalTime.parse("06:30");