8303440: The "ZonedDateTime.parse" may not accept the "UTC+XX" zone id

Reviewed-by: iris, jpai, rriggs, lancea
This commit is contained in:
Naoto Sato 2023-03-06 17:22:52 +00:00
parent a97271e3b5
commit cfb0a25a4e
2 changed files with 81 additions and 2 deletions

View file

@ -4666,8 +4666,10 @@ public final class DateTimeFormatterBuilder {
if (length >= position + 3 && context.charEquals(text.charAt(position + 2), 'C')) {
// There are localized zone texts that start with "UTC", e.g.
// "UTC\u221210:00" (MINUS SIGN instead of HYPHEN-MINUS) in French.
// Exclude those ZoneText cases.
if (!(this instanceof ZoneTextPrinterParser)) {
// Exclude those cases.
if (length == position + 3 ||
context.charEquals(text.charAt(position + 3), '+') ||
context.charEquals(text.charAt(position + 3), '-')) {
return parseOffsetBased(context, text, position, position + 3, OffsetIdPrinterParser.INSTANCE_ID_ZERO);
}
} else {