下面列出了怎么用java.time.chrono.ChronoLocalDateTime的API类实例代码及写法,或者点击链接到github查看源代码。
@Test(dataProvider="calendars")
public void test_badWithAdjusterChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalAdjuster adjuster = new FixedAdjuster(cdt2);
if (chrono != chrono2) {
try {
cdt.with(adjuster);
Assert.fail("WithAdjuster should have thrown a ClassCastException, "
+ "required: " + cdt + ", supplied: " + cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.with(adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date");
}
}
}
@Test(dataProvider="calendars")
public void test_badPlusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalUnit adjuster = new FixedTemporalUnit(cdt2);
if (chrono != chrono2) {
try {
cdt.plus(1, adjuster);
Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + cdt
+ ", can not be cast to " + cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.plus(1, adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date");
}
}
}
@SuppressWarnings("unused")
@Test(dataProvider="samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
MinguoDate hd = minguoDate;
ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
ZoneOffset zo = ZoneOffset.ofHours(1);
ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
hdt = hdt.plus(1, ChronoUnit.NANOS);
ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
MinguoDate a3 = a2.toLocalDate();
MinguoDate a5 = hzdt.toLocalDate();
//System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
@SuppressWarnings("unused")
@Test(dataProvider="samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
MinguoDate hd = minguoDate;
ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
ZoneOffset zo = ZoneOffset.ofHours(1);
ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
hdt = hdt.plus(1, ChronoUnit.NANOS);
ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
MinguoDate a3 = a2.toLocalDate();
MinguoDate a5 = hzdt.toLocalDate();
//System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
@Test(dataProvider="calendars")
public void test_badPlusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalUnit adjuster = new FixedTemporalUnit(cdt2);
if (chrono != chrono2) {
try {
cdt.plus(1, adjuster);
Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + cdt
+ ", can not be cast to " + cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.plus(1, adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date");
}
}
}
@Test(dataProvider="calendars")
public void test_badMinusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalUnit adjuster = new FixedTemporalUnit(cdt2);
if (chrono != chrono2) {
try {
cdt.minus(1, adjuster);
Assert.fail("TemporalUnit.doPlus minus should have thrown a ClassCastException" + cdt.getClass()
+ ", can not be cast to " + cdt2.getClass());
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.minus(1, adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date");
}
}
}
@Test(dataProvider="calendars")
public void test_badPlusTemporalUnitChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalUnit adjuster = new FixedTemporalUnit(cdt2);
if (chrono != chrono2) {
try {
cdt.plus(1, adjuster);
Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + cdt
+ ", can not be cast to " + cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.plus(1, adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date");
}
}
}
@Test(dataProvider="calendars")
public void test_badWithAdjusterChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalAdjuster adjuster = new FixedAdjuster(cdt2);
if (chrono != chrono2) {
try {
cdt.with(adjuster);
Assert.fail("WithAdjuster should have thrown a ClassCastException, "
+ "required: " + cdt + ", supplied: " + cdt2);
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.with(adjuster);
assertEquals(result, cdt2, "WithAdjuster failed to replace date");
}
}
}
@Test(dataProvider="calendars")
public void test_badTemporalFieldChrono(Chronology chrono) {
LocalDate refDate = LocalDate.of(2013, 1, 1);
ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON);
for (Chronology[] clist : data_of_calendars()) {
Chronology chrono2 = clist[0];
ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON);
TemporalField adjuster = new FixedTemporalField(cdt2);
if (chrono != chrono2) {
try {
cdt.with(adjuster, 1);
Assert.fail("TemporalField doWith() should have thrown a ClassCastException" + cdt.getClass()
+ ", can not be cast to " + cdt2.getClass());
} catch (ClassCastException cce) {
// Expected exception; not an error
}
} else {
// Same chronology,
ChronoLocalDateTime<?> result = cdt.with(adjuster, 1);
assertEquals(result, cdt2, "TemporalField doWith() failed to replace date");
}
}
}
@Test(dataProvider="chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
assertEquals(df.format(hdt), expected);
}
@Test()
public void test_MinguoChrono() {
MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3);
MinguoDate h2 = h1;
ChronoLocalDateTime<MinguoDate> h3 = h2.atTime(LocalTime.NOON);
@SuppressWarnings("unused")
ChronoZonedDateTime<MinguoDate> h4 = h3.atZone(ZoneOffset.UTC);
}
@Test()
public void test_MinguoChrono() {
MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3);
MinguoDate h2 = h1;
ChronoLocalDateTime<MinguoDate> h3 = h2.atTime(LocalTime.NOON);
@SuppressWarnings("unused")
ChronoZonedDateTime<MinguoDate> h4 = h3.atZone(ZoneOffset.UTC);
}
@Test()
public void test_MinguoChrono() {
MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3);
MinguoDate h2 = h1;
ChronoLocalDateTime<MinguoDate> h3 = h2.atTime(LocalTime.NOON);
@SuppressWarnings("unused")
ChronoZonedDateTime<MinguoDate> h4 = h3.atZone(ZoneOffset.UTC);
}
@Test()
public void test_MinguoChrono() {
MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3);
MinguoDate h2 = h1;
ChronoLocalDateTime<MinguoDate> h3 = h2.atTime(LocalTime.NOON);
@SuppressWarnings("unused")
ChronoZonedDateTime<MinguoDate> h4 = h3.atZone(ZoneOffset.UTC);
}
void HijrahExample1() {
HijrahDate hd2 = HijrahChronology.INSTANCE.date(1200, 1, 1);
ChronoLocalDateTime<HijrahDate> hdt = hd2.atTime(LocalTime.MIDNIGHT);
ChronoZonedDateTime<HijrahDate> zhdt = hdt.atZone(ZoneId.of("GMT"));
HijrahDate hd3 = zhdt.toLocalDate();
ChronoLocalDateTime<HijrahDate> hdt2 = zhdt.toLocalDateTime();
HijrahDate hd4 = hdt2.toLocalDate();
HijrahDate hd5 = next(hd2);
}
@Test(dataProvider="chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
assertEquals(df.format(hdt), expected);
}
@Test(expectedExceptions = DateTimeParseException.class)
public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_wrongChrono() {
ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
f = f.withChronology(MinguoChronology.INSTANCE);
f.parse("1234567890");
}
@Test(dataProvider="chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
assertEquals(df.format(hdt), expected);
}
@Test(dataProvider="calendars")
public void test_from_TemporalAccessor(Chronology chrono) {
LocalDateTime refDateTime = LocalDateTime.of(2013, 1, 1, 12, 30);
ChronoLocalDateTime<?> dateTime = chrono.localDateTime(refDateTime);
ChronoLocalDateTime<?> test1 = ChronoLocalDateTime.from(dateTime);
assertEquals(test1, dateTime);
ChronoLocalDateTime<?> test2 = ChronoLocalDateTime.from(dateTime.atZone(ZoneOffset.UTC));
assertEquals(test2, dateTime);
}
@Test(expectedExceptions = DateTimeParseException.class)
public void test_fieldResolvesToChronoLocalDateTime_overrideChrono_wrongChrono() {
ChronoLocalDateTime<?> cldt = ThaiBuddhistChronology.INSTANCE.dateNow().atTime(LocalTime.NOON);
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(cldt)).toFormatter();
f = f.withChronology(MinguoChronology.INSTANCE);
f.parse("1234567890");
}
void HijrahExample1() {
HijrahDate hd2 = HijrahChronology.INSTANCE.date(1200, 1, 1);
ChronoLocalDateTime<HijrahDate> hdt = hd2.atTime(LocalTime.MIDNIGHT);
ChronoZonedDateTime<HijrahDate> zhdt = hdt.atZone(ZoneId.of("GMT"));
HijrahDate hd3 = zhdt.toLocalDate();
ChronoLocalDateTime<HijrahDate> hdt2 = zhdt.toLocalDateTime();
HijrahDate hd4 = hdt2.toLocalDate();
HijrahDate hd5 = next(hd2);
}
@Test()
public void test_MinguoChrono() {
MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3);
MinguoDate h2 = h1;
ChronoLocalDateTime<MinguoDate> h3 = h2.atTime(LocalTime.NOON);
@SuppressWarnings("unused")
ChronoZonedDateTime<MinguoDate> h4 = h3.atZone(ZoneOffset.UTC);
}
void HijrahExample1() {
HijrahDate hd2 = HijrahChronology.INSTANCE.date(1200, 1, 1);
ChronoLocalDateTime<HijrahDate> hdt = hd2.atTime(LocalTime.MIDNIGHT);
ChronoZonedDateTime<HijrahDate> zhdt = hdt.atZone(ZoneId.of("GMT"));
HijrahDate hd3 = zhdt.toLocalDate();
ChronoLocalDateTime<HijrahDate> hdt2 = zhdt.toLocalDateTime();
HijrahDate hd4 = hdt2.toLocalDate();
HijrahDate hd5 = next(hd2);
}
@Test(dataProvider="chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
assertEquals(df.format(hdt), expected);
}
@Test(dataProvider="chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
assertEquals(df.format(hdt), expected);
}
@Test(dataProvider="chronoDateTimes")
public void test_formatterOfLocalizedDate(int year, int month, int day, String expected) {
HijrahDate hd = HijrahChronology.INSTANCE.date(year, month, day);
ChronoLocalDateTime<HijrahDate> hdt = hd.atTime(LocalTime.NOON);
hdt = hdt.plus(1, ChronoUnit.YEARS);
hdt = hdt.plus(1, ChronoUnit.MONTHS);
hdt = hdt.plus(1, ChronoUnit.DAYS);
hdt = hdt.plus(1, ChronoUnit.HOURS);
hdt = hdt.plus(1, ChronoUnit.MINUTES);
hdt = hdt.plus(1, ChronoUnit.SECONDS);
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withChronology(Chronology.of("Hijrah-umalqura")).withLocale(Locale.US);
assertEquals(df.format(hdt), expected);
}
private void resolveFields() {
// resolve ChronoField
resolveInstantFields();
resolveDateFields();
resolveTimeFields();
// if any other fields, handle them
// any lenient date resolution should return epoch-day
if (fieldValues.size() > 0) {
int changedCount = 0;
outer:
while (changedCount < 50) {
for (Map.Entry<TemporalField, Long> entry : fieldValues.entrySet()) {
TemporalField targetField = entry.getKey();
TemporalAccessor resolvedObject = targetField.resolve(fieldValues, this, resolverStyle);
if (resolvedObject != null) {
if (resolvedObject instanceof ChronoZonedDateTime) {
ChronoZonedDateTime<?> czdt = (ChronoZonedDateTime<?>) resolvedObject;
if (zone == null) {
zone = czdt.getZone();
} else if (zone.equals(czdt.getZone()) == false) {
throw new DateTimeException("ChronoZonedDateTime must use the effective parsed zone: " + zone);
}
resolvedObject = czdt.toLocalDateTime();
}
if (resolvedObject instanceof ChronoLocalDateTime) {
ChronoLocalDateTime<?> cldt = (ChronoLocalDateTime<?>) resolvedObject;
updateCheckConflict(cldt.toLocalTime(), Period.ZERO);
updateCheckConflict(cldt.toLocalDate());
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
if (resolvedObject instanceof ChronoLocalDate) {
updateCheckConflict((ChronoLocalDate) resolvedObject);
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
if (resolvedObject instanceof LocalTime) {
updateCheckConflict((LocalTime) resolvedObject, Period.ZERO);
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
throw new DateTimeException("Method resolve() can only return ChronoZonedDateTime, " +
"ChronoLocalDateTime, ChronoLocalDate or LocalTime");
} else if (fieldValues.containsKey(targetField) == false) {
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
}
break;
}
if (changedCount == 50) { // catch infinite loops
throw new DateTimeException("One of the parsed fields has an incorrectly implemented resolve method");
}
// if something changed then have to redo ChronoField resolve
if (changedCount > 0) {
resolveInstantFields();
resolveDateFields();
resolveTimeFields();
}
}
}
void test_unknownChronologyWithDateTime() {
ChronoLocalDate date = LocalDate.now();
ChronoLocalDateTime<?> cldt = date.atTime(LocalTime.NOON);
ChronoLocalDate ld = cldt.toLocalDate();
ChronoLocalDateTime<?> noonTomorrow = tomorrowNoon(ld);
}
@Test(expectedExceptions = DateTimeException.class)
public void test_from_TemporalAccessor_dateOnly() {
ChronoLocalDateTime.from(LocalDate.of(2013, 1, 1));
}
private void resolveFields() {
// resolve ChronoField
resolveInstantFields();
resolveDateFields();
resolveTimeFields();
// if any other fields, handle them
// any lenient date resolution should return epoch-day
if (fieldValues.size() > 0) {
int changedCount = 0;
outer:
while (changedCount < 50) {
for (Map.Entry<TemporalField, Long> entry : fieldValues.entrySet()) {
TemporalField targetField = entry.getKey();
TemporalAccessor resolvedObject = targetField.resolve(fieldValues, this, resolverStyle);
if (resolvedObject != null) {
if (resolvedObject instanceof ChronoZonedDateTime) {
ChronoZonedDateTime<?> czdt = (ChronoZonedDateTime<?>) resolvedObject;
if (zone == null) {
zone = czdt.getZone();
} else if (zone.equals(czdt.getZone()) == false) {
throw new DateTimeException("ChronoZonedDateTime must use the effective parsed zone: " + zone);
}
resolvedObject = czdt.toLocalDateTime();
}
if (resolvedObject instanceof ChronoLocalDateTime) {
ChronoLocalDateTime<?> cldt = (ChronoLocalDateTime<?>) resolvedObject;
updateCheckConflict(cldt.toLocalTime(), Period.ZERO);
updateCheckConflict(cldt.toLocalDate());
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
if (resolvedObject instanceof ChronoLocalDate) {
updateCheckConflict((ChronoLocalDate) resolvedObject);
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
if (resolvedObject instanceof LocalTime) {
updateCheckConflict((LocalTime) resolvedObject, Period.ZERO);
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
throw new DateTimeException("Method resolve() can only return ChronoZonedDateTime, " +
"ChronoLocalDateTime, ChronoLocalDate or LocalTime");
} else if (fieldValues.containsKey(targetField) == false) {
changedCount++;
continue outer; // have to restart to avoid concurrent modification
}
}
break;
}
if (changedCount == 50) { // catch infinite loops
throw new DateTimeException("One of the parsed fields has an incorrectly implemented resolve method");
}
// if something changed then have to redo ChronoField resolve
if (changedCount > 0) {
resolveInstantFields();
resolveDateFields();
resolveTimeFields();
}
}
}