Skip to content

Commit

Permalink
ICU-22444 Remove "unknown" from Calendar.getKeywordValuesForLocale
Browse files Browse the repository at this point in the history
Remove CalType enum value UNKNOWN and use null for unknown CalType
This value is an internal enum and the only place use it is inside Calendar.java
Use null for that instead (same as C++)
  • Loading branch information
FrankYFTang committed Jul 28, 2023
1 parent 03e98c0 commit 73b61ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions icu4j/main/classes/core/src/com/ibm/icu/impl/CalType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public enum CalType {
ISLAMIC_UMALQURA("islamic-umalqura"),
JAPANESE("japanese"),
PERSIAN("persian"),
ROC("roc"),

UNKNOWN("unknown");
ROC("roc");

String id;

Expand Down
4 changes: 2 additions & 2 deletions icu4j/main/classes/core/src/com/ibm/icu/util/Calendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -1814,14 +1814,14 @@ private static CalType getCalendarTypeForLocale(ULocale l) {
}
}
}
return CalType.UNKNOWN;
return null;
}

private static Calendar createInstance(ULocale locale) {
Calendar cal = null;
TimeZone zone = TimeZone.forULocaleOrDefault(locale);
CalType calType = getCalendarTypeForLocale(locale);
if (calType == CalType.UNKNOWN) {
if (calType == null) {
// fallback to Gregorian
calType = CalType.GREGORIAN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,9 @@ public void TestGetKeywordValuesForLocale(){
String[] ALL = Calendar.getKeywordValuesForLocale("calendar", ULocale.getDefault(), false);
HashSet ALLSET = new HashSet();
for (int i = 0; i < ALL.length; i++) {
if (ALL[i] == "unknown") {
errln("Calendar.getKeywordValuesForLocale should not return \"unknown\"");
}
ALLSET.add(ALL[i]);
}

Expand Down

0 comments on commit 73b61ce

Please sign in to comment.