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).
DateMidnight dt = new DateMidnight(1972, 12, 3); int year = dt.year().get(); String monthStr = dt.monthOfYear().getAsText();
Methods are also provided that allow date modification. These return new instances of DateMidnight - they do not modify the original. The example below yields two independent immutable date objects 20 years apart.
DateMidnight dt = new DateMidnight(1972, 12, 3); DateMidnight dt20 = dt.year().addToCopy(20);Serious modification of dates (ie. more than just changing one or two fields) should use the {@link org.joda.time.MutableDateTime MutableDateTime} class.
DateMidnight.Property itself is thread-safe and immutable. @author Stephen Colebourne @author Brian S O'Neill @since 1.0
|
|
|
|