Replace Calendar with LocalDate in Java programs
Developers often need to perform programming operations such as retrieving the current date, manipulating dates, and formatting dates in their applications. While Java's traditional java.util.Calendar
class had its day, the newer LocalDate
class does more with significantly fewer lines of code. This article introduces you to LocalDate
and the java.time
API for using dates, times, and durations in your programs.
Note: Introduced in Java 8, java.time
standardizes many elements of the popular Joda-Time library. Concepts introduced here can be applied to either library but the JDK standard is generally recommended.