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).
LocalDateTime dt = new LocalDateTime(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 LocalDateTime - they do not modify the original. The example below yields two independent immutable date objects 20 years apart.
LocalDateTime dt = new LocalDateTime(1972, 12, 3, 0, 0); LocalDateTime dt1920 = dt.year().setCopy(1920);
LocalDateTime.Property itself is thread-safe and immutable, as well as the LocalDateTime being operated on. @author Stephen Colebourne @author Brian S O'Neill @since 1.3
|
|
|
|