This decision is over what values should be returned from the getXxx() methods on the calendar classes. It may potentially impact the withXxx() and plusXxx() methods too.
This option would see calendar classes return ints, or enums when an int would have no meaning. As such, getMonthOfYear() would return an int, because the int has meaning.
Additional methods would be supplied to provide access to the month of year enum.
int year = dt.getYear();
int month = dt.getMonthOfYear();
int dom = dt.getDayOfMonth();
DayOfWeek dow = dt.getDayOfWeek();
MonthOfYear moy = dt.monthOfYear();
Year year = dt.year();
boolean leap = dt.year().isLeap();
This approach aims to provide the common int access wherever possible. It is inconsistent between the different fields however.
Note also, that this will cause each calendar class to have both a getMonthOfYear() and monthOfYear() method (one int, one Enum). Also a getYear() and year() method (one int, one Object).
This option would see calendar classes return objects (including enums) from the getters. The only way to access the int value would be via a method on the object.
int year = dt.getYear().getValue();
int month = dt.getMonthOfYear().getValue();
int dom = dt.getDayOfMonth().getValue();
DayOfWeek dow = dt.getDayOfWeek();
MonthOfYear moy = dt.getMonthOfYear();
Year year = dt.getYear();
boolean leap = dt.getYear().isLeap();
This approach is consistent between the different fields. However, accessing the int value takes another step.
This approach provides good access to secondary level information, without cluttering the API of the calendar classes.
For example,
date.getYear().getEra()
,
date.getYear().getCenturyEra()
or
time.getHourOfDay().isAm()
It should be noted that a property syntax for Java (possible Java 7 feature) would simplify some of these:
int year = dt.year.value;
int month = dt.monthOfYear.value;
int dom = dt.dayOfMonth.value;
DayOfWeek dow = dt.dayOfWeek;
MonthOfYear moy = dt.monthOfYear;
Year year = dt.year;
boolean leap = dt.year.leap;
This option would see calendar classes return objects (including enums) from the getters, but there would be additional getters provided to access the primitive int value.
int year = dt.getYearValue();
int month = dt.getMonthOfYearValue();
int dom = dt.getDayOfMonthValue();
DayOfWeek dow = dt.getDayOfWeek();
MonthOfYear moy = dt.getMonthOfYear();
Year year = dt.getYear();
boolean leap = dt.getYear().isLeap();
This approach is consistent between the different fields for getters. It also provides quick access to the int value. However, it does double the number of get methods.