@@ -52,6 +52,7 @@ public enum LocalOrGmt {
5252 private static Function <Locale , FormatFixer > LocaleFixerFunction ;
5353
5454 // controlls leniency of parsing date. using non-lenient mode for not allowing ambiguous date such as "2/30"
55+ // set true to avoid ICU-21301 that fails to parse the transition date for time zones with daylight saving time
5556 private static final boolean USE_LENIENT_MODE = false ;
5657
5758 static {
@@ -822,22 +823,6 @@ public DateFormat getInputLongDateFormat() {
822823 return this .inputLocalLongDateFormat ;
823824 }
824825
825-
826- /**
827- * Copy over the settings from ICU {@code SimpleDateFormat}.
828- * <p>
829- * ICU-21301 fails to parse the transition date for time zones with daylight saving time.
830-
831- * see: https://unicode-org.atlassian.net/browse/ICU-21301
832- */
833- private static DateFormat setJdkDateFormatFromIcu (SimpleDateFormat fmtJdk , SimpleDateFormatICU fmtIcu ) {
834- fmtJdk .applyPattern (fmtIcu .toPattern ());
835- fmtJdk .setNumberFormat (fmtIcu .getNumberFormat ());
836- fmtJdk .setDateFormatSymbols (fmtIcu .getDateFormatSymbols ());
837- fmtJdk .set2DigitYearStart (fmtIcu .get2DigitYearStart ());
838- return fmtJdk ;
839- }
840-
841826 /**
842827 * Static method to get date-only DateFormat for input. This is based on a 2 digit year
843828 * input mask, which also handles 4-digit year, but caller must use doParseDate() to
@@ -850,13 +835,6 @@ private static DateFormat setJdkDateFormatFromIcu(SimpleDateFormat fmtJdk, Simpl
850835 */
851836 public static DateFormat getLocaleInputDateFormat (Locale locale , TimeZone tz ) {
852837 DateFormat df = getFormatProvider (locale ).getDateInstance (DateFormat .SHORT , locale );
853- // ICU-21301 hack: Apply only with an ICU object and when timezone has DST
854- if (!USE_LENIENT_MODE && df instanceof SimpleDateFormatICU && tz .useDaylightTime ()) {
855- // (re-)construct JDK's DateFormat object and copy formatting information from ICU
856- DateFormat dfJdk = getJDKFormatFixer ().getDateInstance (DateFormat .SHORT , locale );
857- df = setJdkDateFormatFromIcu ((SimpleDateFormat )dfJdk , (SimpleDateFormatICU )df );
858- }
859-
860838 df .setLenient (USE_LENIENT_MODE );
861839 df .setTimeZone (tz );
862840 set2DigitYearStart (df , tz );
@@ -885,13 +863,6 @@ public static DateFormat getLocaleInputDateFormat(Locale locale, int style, Time
885863 dateStyle = DateFormat .SHORT ;
886864 }
887865 DateFormat df = getFormatProvider (locale ).getDateInstance (dateStyle , locale );
888- // ICU-21301 hack: Apply only with an ICU object and when timezone has DST
889- if (!USE_LENIENT_MODE && df instanceof SimpleDateFormatICU && tz .useDaylightTime ()) {
890- // (re-)construct JDK's DateFormat object and copy formatting information from ICU
891- DateFormat dfJdk = getJDKFormatFixer ().getDateInstance (dateStyle , locale );
892- df = setJdkDateFormatFromIcu ((SimpleDateFormat )dfJdk , (SimpleDateFormatICU )df );
893- }
894-
895866 df .setLenient (USE_LENIENT_MODE );
896867 df .setTimeZone (tz );
897868 set2DigitYearStart (df , tz );
@@ -986,13 +957,6 @@ public DateFormat getInputLongDateTimeFormat() {
986957 */
987958 public static DateFormat getLocaleInputDateTimeFormat (Locale locale , TimeZone tz ) {
988959 DateFormat df = getFormatProvider (locale ).getDateTimeInstance (DateFormat .SHORT , DateFormat .SHORT , locale );
989- // ICU-21301 hack: Apply only with an ICU object and when timezone has DST
990- if (!USE_LENIENT_MODE && df instanceof SimpleDateFormatICU && tz .useDaylightTime ()) {
991- // (re-)construct JDK's DateFormat object and copy formatting information from ICU
992- DateFormat dfJdk = getJDKFormatFixer ().getDateTimeInstance (DateFormat .SHORT , DateFormat .SHORT , locale );
993- df = setJdkDateFormatFromIcu ((SimpleDateFormat )dfJdk , (SimpleDateFormatICU )df );
994- }
995-
996960 df .setLenient (USE_LENIENT_MODE );
997961 df .setTimeZone (tz );
998962 set2DigitYearStart (df , tz );
@@ -1027,12 +991,6 @@ public static DateFormat getLocaleInputDateTimeFormat(Locale locale, int style,
1027991 dateStyle = timeStyle = DateFormat .SHORT ;
1028992 }
1029993 DateFormat df = getFormatProvider (locale ).getDateTimeInstance (dateStyle , timeStyle , locale );
1030- // ICU-21301 hack: Apply only with an ICU object and when timezone has DST
1031- if (!USE_LENIENT_MODE && df instanceof SimpleDateFormatICU && tz .useDaylightTime ()) {
1032- // (re-)construct JDK's DateFormat object and copy formatting information from ICU
1033- DateFormat dfJdk = getJDKFormatFixer ().getDateTimeInstance (dateStyle , timeStyle , locale );
1034- df = setJdkDateFormatFromIcu ((SimpleDateFormat )dfJdk , (SimpleDateFormatICU )df );
1035- }
1036994 df .setLenient (USE_LENIENT_MODE );
1037995 df .setTimeZone (tz );
1038996 set2DigitYearStart (df , tz );
@@ -1101,13 +1059,6 @@ public static DateFormat getLocaleInputTimeFormat(Locale locale, int style, Time
11011059 dateStyle = DateFormat .SHORT ;
11021060 }
11031061 DateFormat df = getFormatProvider (locale ).getTimeInstance (dateStyle , locale );
1104- // ICU-21301 hack: Apply only with an ICU object and when timezone has DST
1105- if (!USE_LENIENT_MODE && df instanceof SimpleDateFormatICU && tz .useDaylightTime ()) {
1106- // (re-)construct JDK's DateFormat object and copy formatting information from ICU
1107- DateFormat dfJdk = getJDKFormatFixer ().getTimeInstance (dateStyle , locale );
1108- df = setJdkDateFormatFromIcu ((SimpleDateFormat )dfJdk , (SimpleDateFormatICU )df );
1109- }
1110-
11111062 df .setLenient (USE_LENIENT_MODE );
11121063 df .setTimeZone (tz );
11131064 set2DigitYearStart (df , tz );
0 commit comments