Java 8 LocalDate Class explained with code samples
Another new feature by Java 8 is the DateTime API. Some of the important classes in the DateTime API are the LocalDate, LocalTime and LocalDateTime . In this article, I will be explaining the Java 8 LocalDate class in detail. Edit Introduction The LocalDate class represents a date. It is present in the java.time package. It has several methods that allow you to perform date manipulation easily. Creating LocalDate There are several static methods on the LocalDate class that allow you to obtain a LocalDate instance. The following code demonstrates this: public class LocalDateDemo { public static void main(String[] args) { LocalDate date1 = LocalDate.now(); System.out.println("Today's date is "+date1); LocalDate date2 = LocalDate.parse("2019-07-15"); System.out.println("Date2 is "+date2); LocalDate date3 = LocalDate.of(2017,05,17); System.out.println("Date3 is "+date3 ); LocalDate date4 = LocalDate.ofYear