Learn to compare two LocalDateTime instances to find out which date represents an older timestamp in comparison to other timestamp. LocalDateTime class is part of java.time package added in Java 8.
Learn to compare two LocalDate instances to find out which date represents an older date in comparison to second date. LocalDate class is part of java.time package added in Java 8.
Learn to format date and time in either 12 hours pattern. The formatted date string will have the AM/PM information as applicable to the timestamp.
Java 8 examples to format LocalDate to String in default patterns as well as custom date patterns. 1. Default pattern [yyyy-MM-dd] If we use the LocalDate.toString() method then it format the date in default format which is yyyy-MM-dd. The default pattern referenced in DateTimeFormatter.ISO_LOCAL_DATE. DateTimeFormatter.ISO_DATE also produces the same result. Program output. 2. Custom patterns […]
Learn to determine, if the given year is leap year, using different Java date time classes including Calendar, ZonedDateTime and LocalDateTime in Java 8.