Skip to content

Commit

Permalink
Fix standalone month names in desugar_jdk_libs
Browse files Browse the repository at this point in the history
- Fix off-by-one issues: from 1..11 to 1..12

PiperOrigin-RevId: 665969922
  • Loading branch information
dx404 authored and Javac Team committed Aug 21, 2024
1 parent 43b2457 commit d0e9427
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void fillWithStandaloneStyleMap(
String longMonth = "LLLL";
String shortMonth = "LLL";

for (int i = 1; i < numMonth; i++) {
for (int i = 1; i <= numMonth; i++) {
String longName = computeStandaloneMonthName(i, longMonth, loc);
longStandAloneMap.put((long) i, longName);
narrowStandAloneMap.put((long) i, firstCodePoint(longName));
Expand All @@ -56,9 +56,6 @@ public static void fillWithStandaloneStyleMap(
}

if (numMonth > 0) {
longStandAloneMap.put((long) numMonth, "");
narrowStandAloneMap.put((long) numMonth, "");
shortStandAloneMap.put((long) numMonth, "");
styleMapMap.put(TextStyle.FULL_STANDALONE, longStandAloneMap);
styleMapMap.put(TextStyle.NARROW_STANDALONE, narrowStandAloneMap);
styleMapMap.put(TextStyle.SHORT_STANDALONE, shortStandAloneMap);
Expand All @@ -70,7 +67,8 @@ private static String computeStandaloneMonthName(int id, String standalonePatter
SimpleDateFormat writer = new SimpleDateFormat(standalonePattern, loc);
writer.setTimeZone(legacyUtc);
Calendar calendar = Calendar.getInstance();
calendar.set(0, id, 0);
calendar.setTimeZone(legacyUtc);
calendar.set(0, id, 0, 0, 0, 0);
Date legacy = calendar.getTime();
return writer.format(legacy);
}
Expand Down

0 comments on commit d0e9427

Please sign in to comment.