[threeten-dev] some questions for with() method in java.time.chrono.ChronoLocalDate
Patrick Zhang
patrick.zhang at oracle.com
Fri Jul 12 03:23:56 PDT 2013
Hi Team,
I am reading source code of threeten project and find something strange
in java.time.chrono.ChronoLocalDate.
There are 2 with() methods, mostly I am confused by below:
======
default ChronoLocalDate with(TemporalField field, long newValue) {
if (field instanceof ChronoField) {
throw new UnsupportedTemporalTypeException("Unsupported
field: " + field);
}
return ChronoDateImpl.ensureValid(getChronology(),
field.adjustInto(this, newValue));
}
======
As you know, ChronoLocalDate with(TemporalField field, long newValue) is
not DEFAULT in ChronoLocalDateTime and ChronoZonedDateTime.
1. Why we make it as default in ChronoLocalDate?
2. The implement looks strange. Why it does not support standard
ChronoField and must throw UnsupportedTemporalTypeException explicitly?
Regards
Patrick
More information about the threeten-dev
mailing list