{"record":{"id":"63a59da13dda7354","repo":"stanfordnlp/CoreNLP","slug":"different-chronology-c1-c1-c2-c2","errorCode":null,"errorMessage":"Different chronology: c1=${c1}, c2=${c2}","messagePattern":"Different chronology: c1=(.+?), c2=(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/JodaTimeUtils.java","lineNumber":447,"sourceCode":"        }\n       // PeriodType.forFields(new DurationFieldType[]{dType});\n       // return new Period(df.getUnitMillis(), PeriodType.forFields(new DurationFieldType[]{dType}));\n\n      }\n    }\n    return null;\n  }\n  public static Partial combineMoreGeneralFields(Partial p1, Partial p2) {\n    return combineMoreGeneralFields(p1, p2, null);\n  }\n\n  // Combines more general fields from p2 to p1\n  public static Partial combineMoreGeneralFields(Partial p1, Partial p2, DateTimeFieldType mgf) {\n    Partial p = p1;\n    Chronology c1 = p1.getChronology();\n    Chronology c2 = p2.getChronology();\n    if (!c1.equals(c2)) {\n      throw new RuntimeException(\"Different chronology: c1=\" + c1 + \", c2=\" + c2);\n    }\n    DateTimeFieldType p1MostGeneralField = null;\n    if (p1.size() > 0) {\n      p1MostGeneralField = p1.getFieldType(0);    // Assume fields ordered from most general to least....\n    }\n    if (mgf == null || (p1MostGeneralField != null && isMoreGeneral(p1MostGeneralField, mgf, c1))) {\n      mgf = p1MostGeneralField;\n    }\n    for (int i = 0; i < p2.size(); i++) {\n      DateTimeFieldType fieldType = p2.getFieldType(i);\n      if (fieldType == DateTimeFieldType.year()) {\n        if (p.isSupported(DateTimeFieldType.yearOfCentury())) {\n          if (!p.isSupported(DateTimeFieldType.centuryOfEra())) {\n            int yoc = p.get(DateTimeFieldType.yearOfCentury());\n            int refYear = p2.getValue(i);\n            int century = refYear / 100;\n            int y2 = yoc + century*100;\n            // TODO: Figure out which way to go","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/JodaTimeUtils.java#L429-L465","documentation":"combineMoreGeneralFields merges the more general fields of one Joda-Time Partial into another. It requires both Partials to be built on the exact same Chronology object (e.g. both ISOChronology); mixing chronologies would make field comparisons like isMoreGeneral meaningless, so the library throws a RuntimeException immediately when c1.equals(c2) fails.","triggerScenarios":"Calling JodaTimeUtils.combineMoreGeneralFields(p1, p2, mgf) (or its recursive overload) where p1 and p2 were created with different Chronologies, e.g. one from ISOChronology.getInstance() and another from a BuddhistChronology, GJChronology, or a chronology with a different time zone ( Chronologies with different zones are not equal).","commonSituations":"Mixing Partial objects parsed by different code paths that apply custom chronologies or zones; passing a Partial deserialized from an older serialization that restored a different chronology; constructing one Partial with DateTimeUtils default zone changed mid-run.","solutions":["Ensure both Partials use the same chronology: rebuild one with p2.withChronology(p1.getChronology()) or construct both with the same DateTimeZone/chronology before calling.","Normalize to UTC or a single shared DateTimeZone when creating Partials (e.g. ISOChronology.getInstance(DateTimeZone.UTC)).","If chronologies must differ, convert values field-by-field into a new Partial on the target chronology instead of calling combineMoreGeneralFields directly."],"exampleFix":"// before\nPartial combined = JodaTimeUtils.combineMoreGeneralFields(p1, p2, null);\n// after\nif (!p1.getChronology().equals(p2.getChronology())) {\n  p2 = p2.withChronology(p1.getChronology());\n}\nPartial combined = JodaTimeUtils.combineMoreGeneralFields(p1, p2, null);","handlingStrategy":"validation","validationCode":"if (!p1.getChronology().equals(p2.getChronology())) {\n  p2 = p2.withChronology(p1.getChronology());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create all Partials from one shared Chronology/DateTimeZone constant","Normalize chronology before temporal operations on third-party Partials"],"tags":["joda-time","chronology","temporal-annotation","precondition"],"backgroundTag":"type-mismatch","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}