@@ -52,6 +52,7 @@ public enum LocalOrGmt {
52
52
private static Function <Locale , FormatFixer > LocaleFixerFunction ;
53
53
54
54
// 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
55
56
private static final boolean USE_LENIENT_MODE = false ;
56
57
57
58
static {
@@ -822,22 +823,6 @@ public DateFormat getInputLongDateFormat() {
822
823
return this .inputLocalLongDateFormat ;
823
824
}
824
825
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
-
841
826
/**
842
827
* Static method to get date-only DateFormat for input. This is based on a 2 digit year
843
828
* 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
850
835
*/
851
836
public static DateFormat getLocaleInputDateFormat (Locale locale , TimeZone tz ) {
852
837
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
-
860
838
df .setLenient (USE_LENIENT_MODE );
861
839
df .setTimeZone (tz );
862
840
set2DigitYearStart (df , tz );
@@ -885,13 +863,6 @@ public static DateFormat getLocaleInputDateFormat(Locale locale, int style, Time
885
863
dateStyle = DateFormat .SHORT ;
886
864
}
887
865
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
-
895
866
df .setLenient (USE_LENIENT_MODE );
896
867
df .setTimeZone (tz );
897
868
set2DigitYearStart (df , tz );
@@ -986,13 +957,6 @@ public DateFormat getInputLongDateTimeFormat() {
986
957
*/
987
958
public static DateFormat getLocaleInputDateTimeFormat (Locale locale , TimeZone tz ) {
988
959
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
-
996
960
df .setLenient (USE_LENIENT_MODE );
997
961
df .setTimeZone (tz );
998
962
set2DigitYearStart (df , tz );
@@ -1027,12 +991,6 @@ public static DateFormat getLocaleInputDateTimeFormat(Locale locale, int style,
1027
991
dateStyle = timeStyle = DateFormat .SHORT ;
1028
992
}
1029
993
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
- }
1036
994
df .setLenient (USE_LENIENT_MODE );
1037
995
df .setTimeZone (tz );
1038
996
set2DigitYearStart (df , tz );
@@ -1101,13 +1059,6 @@ public static DateFormat getLocaleInputTimeFormat(Locale locale, int style, Time
1101
1059
dateStyle = DateFormat .SHORT ;
1102
1060
}
1103
1061
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
-
1111
1062
df .setLenient (USE_LENIENT_MODE );
1112
1063
df .setTimeZone (tz );
1113
1064
set2DigitYearStart (df , tz );
0 commit comments