{"record":{"id":"4c0c5e3fae448779","repo":"chinabugotech/hutool","slug":"the-locale-does-not-support-dates-before-1868","errorCode":null,"errorMessage":"(The {} locale does not support dates before 1868 AD)\nUnparseable date: \"{}","messagePattern":"\\(The (.+?) locale does not support dates before 1868 AD\\)\nUnparseable date: \"(.+?)","errorType":"exception","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/date/format/FastDateParser.java","lineNumber":219,"sourceCode":"\t * @param in ObjectInputStream from which the object is being deserialized.\n\t * @throws IOException            if there is an IO issue.\n\t * @throws ClassNotFoundException if a class cannot be found.\n\t */\n\tprivate void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {\n\t\tin.defaultReadObject();\n\n\t\tfinal Calendar definingCalendar = Calendar.getInstance(timeZone, locale);\n\t\tinit(definingCalendar);\n\t}\n\n\t@Override\n\tpublic Date parse(String source) throws ParseException {\n\t\tfinal ParsePosition pp = new ParsePosition(0);\n\t\tfinal Date date = parse(source, pp);\n\t\tif (date == null) {\n\t\t\t// Add a note re supported date range\n\t\t\tif (locale.equals(JAPANESE_IMPERIAL)) {\n\t\t\t\tthrow new ParseException(\"(The \" + locale + \" locale does not support dates before 1868 AD)\\n\" +\n\t\t\t\t\t\t\"Unparseable date: \\\"\" + source, pp.getErrorIndex());\n\t\t\t}\n\t\t\tthrow new ParseException(\"Unparseable date: \" + source, pp.getErrorIndex());\n\t\t}\n\t\treturn date;\n\t}\n\n\t@Override\n\tpublic Date parse(String source, ParsePosition pos) {\n\t\t// timing tests indicate getting new instance is 19% faster than cloning\n\t\tfinal Calendar cal = Calendar.getInstance(timeZone, locale);\n\t\tcal.clear();\n\n\t\treturn parse(source, pos, cal) ? cal.getTime() : null;\n\t}\n\n\t@Override\n\tpublic boolean parse(String source, ParsePosition pos, Calendar calendar) {","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/date/format/FastDateParser.java#L201-L237","documentation":"Thrown by FastDateParser.parse(String) when the Japanese Imperial calendar locale (ja_JP_JP / Locale with JAPANESE_IMPERIAL calendar) is in use and the date being parsed resolves to a year before 1868 AD, which precedes the Meiji era and has no representation in that calendar system. It wraps the generic 'Unparseable date' with a locale-specific note.","triggerScenarios":"Parsing a string such as '1800-01-01' with a FastDateFormat configured for Locale.JAPANESE_IMPERIAL (typically Locale = new Locale(\"ja\",\"JP\",\"JP\") which triggers the Japanese Imperial calendar). Any parsed year < 1868 triggers it, even if the pattern itself matches.","commonSituations":"Server/app default Locale set to Japanese Imperial via config or container locale negotiation; legacy data containing historical dates being parsed in a locale-aware component; tests run on a JVM whose default locale resolves to the imperial calendar.","solutions":["Parse with a Gregorian/proleptic locale (e.g. Locale.US or Locale.JAPAN) instead of the imperial Japanese locale.","Filter or reject dates before 1868 before attempting parse in the imperial locale.","Set the JVM default locale away from ja_JP_JP if it was inherited unintentionally."],"exampleFix":"// before\nFastDateFormat fdf = FastDateFormat.getInstance(\"yyyy-MM-dd\", tz, new Locale(\"ja\",\"JP\",\"JP\"));\nfdf.parse(\"1800-01-01\");\n// after\nFastDateFormat fdf = FastDateFormat.getInstance(\"yyyy-MM-dd\", tz, Locale.US);\nfdf.parse(\"1800-01-01\");","handlingStrategy":"validation","validationCode":"boolean isImperial(Locale l){ return l!=null && \"JP\".equals(l.getCountry()) && \"ja\".equals(l.getLanguage()) && \"JP\".equals(l.getVariant()); }\n// if isImperial(locale) && parsedYear<1868 -> use a Gregorian locale","typeGuard":null,"tryCatchPattern":"try { return fdf.parse(source); }\ncatch (ParseException e) { if (e.getMessage().contains(\"does not support dates before 1868\")) { return gregorianFdf.parse(source); } throw e; }","preventionTips":["Pin the parsing locale to a Gregorian one for historical dates.","Avoid inheriting the JVM default locale for date parsing.","Document locale requirements in your config schema."],"tags":["date","parsing","locale","japanese-imperial-calendar","argument"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}