--- old/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java 2017-11-10 15:30:18.460331856 -0800 +++ new/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java 2017-11-10 15:30:18.132325725 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -120,6 +120,7 @@ import java.util.concurrent.ConcurrentMap; import sun.text.spi.JavaTimeDateTimePatternProvider; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; import sun.util.locale.provider.TimeZoneNameUtility; @@ -216,7 +217,8 @@ LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(JavaTimeDateTimePatternProvider.class, locale); JavaTimeDateTimePatternProvider provider = adapter.getJavaTimeDateTimePatternProvider(); String pattern = provider.getJavaTimeDateTimePattern(convertStyle(timeStyle), - convertStyle(dateStyle), chrono.getCalendarType(), locale); + convertStyle(dateStyle), chrono.getCalendarType(), + CalendarDataUtility.findRegionOverride(locale).orElse(locale)); return pattern; } @@ -2160,6 +2162,12 @@ * This will create a formatter with the {@linkplain Locale#getDefault(Locale.Category) default FORMAT locale}. * Numbers will be printed and parsed using the standard DecimalStyle. * The resolver style will be {@link ResolverStyle#SMART SMART}. + * If the default locale contains "ca" (calendar), "rg" (region override) + * and/or "tz" (timezone) + * Unicode extensions, + * the chronology and/or the zone are overriden. If both "ca" and "rg" are + * specified, the chronology from "ca" extension supersedes the implicit one + * from "rg" extension. *

* Calling this method will end any open optional sections by repeatedly * calling {@link #optionalEnd()} before creating the formatter. @@ -2180,6 +2188,12 @@ * This will create a formatter with the specified locale. * Numbers will be printed and parsed using the standard DecimalStyle. * The resolver style will be {@link ResolverStyle#SMART SMART}. + * If the specified locale contains "ca" (calendar), "rg" (region override) + * and/or "tz" (timezone) + * Unicode extensions, + * the chronology and/or the zone are overriden. If both "ca" and "rg" are + * specified, the chronology from "ca" extension supersedes the implicit one + * from "rg" extension. *

* Calling this method will end any open optional sections by repeatedly * calling {@link #optionalEnd()} before creating the formatter. @@ -2218,8 +2232,18 @@ optionalEnd(); } CompositePrinterParser pp = new CompositePrinterParser(printerParsers, false); + + // Check for chronology/timezone in locale object + Chronology c = locale.getUnicodeLocaleType("ca") != null ? + Chronology.ofLocale(locale) : chrono; + String tzType = locale.getUnicodeLocaleType("tz"); + ZoneId z = tzType != null ? + TimeZoneNameUtility.convertLDMLShortID(tzType) + .map(ZoneId::of) + .orElse(null) : + null; return new DateTimeFormatter(pp, locale, DecimalStyle.STANDARD, - resolverStyle, null, chrono, null); + resolverStyle, null, c, z); } //-----------------------------------------------------------------------