The simplest use of this class is as an alternative get method, here used to get the year '1972' (as an int) and the month 'December' (as a String).
LocalDate dt = new LocalDate(1972, 12, 3, 0, 0); int year = dt.year().get(); String monthStr = dt.month().getAsText();
Methods are also provided that allow date modification. These return new instances of LocalDate - they do not modify the original. The example below yields two independent immutable date objects 20 years apart.
LocalDate dt = new LocalDate(1972, 12, 3); LocalDate dt1920 = dt.year().setCopy(1920);
LocalDate.Property itself is thread-safe and immutable, as well as the LocalDate being operated on. @author Stephen Colebourne @author Brian S O'Neill @since 1.3
|
|
|
|