Fix, lambda & in-line single use variable that cannot be null.

This commit is contained in:
Gary Gregory 2022-05-15 16:01:00 -04:00
parent cbe3523b12
commit af157c49d5
1 changed files with 1 additions and 4 deletions

View File

@ -95,15 +95,12 @@ public class CalendarUtils {
String[] getMonthDisplayNames(final int style) {
// Unfortunately standalone month names are not available in DateFormatSymbols,
// so we have to extract them.
final Calendar calendar = Calendar.getInstance(locale);
final Map<String, Integer> displayNames = calendar.getDisplayNames(Calendar.MONTH, style, locale);
if (displayNames == null) {
return null;
}
final String[] monthNames = new String[displayNames.size()];
for (final Map.Entry<String, Integer> entry: displayNames.entrySet()) {
monthNames[entry.getValue()] = entry.getKey();
}
displayNames.forEach((k, v) -> monthNames[v] = k);
return monthNames;
}