|
33 | 33 |
|
34 | 34 | import java.util.ArrayList;
|
35 | 35 | import java.util.HashMap;
|
| 36 | +import java.util.List; |
36 | 37 | import java.util.Locale;
|
37 | 38 | import java.util.Map;
|
38 | 39 | import java.util.Objects;
|
|
41 | 42 | import org.threeten.bp.ZoneId;
|
42 | 43 | import org.threeten.bp.chrono.Chronology;
|
43 | 44 | import org.threeten.bp.chrono.IsoChronology;
|
| 45 | +import org.threeten.bp.format.DateTimeFormatterBuilder.ReducedPrinterParser; |
44 | 46 | import org.threeten.bp.jdk8.DefaultInterfaceTemporalAccessor;
|
45 | 47 | import org.threeten.bp.jdk8.Jdk8Methods;
|
46 | 48 | import org.threeten.bp.temporal.TemporalField;
|
@@ -355,7 +357,24 @@ int setParsedField(TemporalField field, long value, int errorPos, int successPos
|
355 | 357 | */
|
356 | 358 | void setParsed(Chronology chrono) {
|
357 | 359 | Objects.requireNonNull(chrono, "chrono");
|
358 |
| - currentParsed().chrono = chrono; |
| 360 | + Parsed currentParsed = currentParsed(); |
| 361 | + currentParsed.chrono = chrono; |
| 362 | + if (currentParsed.callbacks != null) { |
| 363 | + List<Object[]> callbacks = new ArrayList<>(currentParsed.callbacks); |
| 364 | + currentParsed.callbacks.clear(); |
| 365 | + for (Object[] objects : callbacks) { |
| 366 | + ReducedPrinterParser pp = (ReducedPrinterParser) objects[0]; |
| 367 | + pp.setValue(this, (long) objects[1], (int) objects[2], (int) objects[3]); |
| 368 | + } |
| 369 | + } |
| 370 | + } |
| 371 | + |
| 372 | + void addChronologyChangedParser(ReducedPrinterParser reducedPrinterParser, long value, int errorPos, int successPos) { |
| 373 | + Parsed currentParsed = currentParsed(); |
| 374 | + if (currentParsed.callbacks == null) { |
| 375 | + currentParsed.callbacks = new ArrayList<>(2); |
| 376 | + } |
| 377 | + currentParsed.callbacks.add(new Object[] {reducedPrinterParser, value, errorPos, successPos}); |
359 | 378 | }
|
360 | 379 |
|
361 | 380 | /**
|
@@ -410,6 +429,7 @@ final class Parsed extends DefaultInterfaceTemporalAccessor {
|
410 | 429 | final Map<TemporalField, Long> fieldValues = new HashMap<>();
|
411 | 430 | boolean leapSecond;
|
412 | 431 | Period excessDays = Period.ZERO;
|
| 432 | + List<Object[]> callbacks; |
413 | 433 |
|
414 | 434 | private Parsed() {
|
415 | 435 | }
|
|
0 commit comments