mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8257964: Broken Calendar#getMinimalDaysInFirstWeek with java.locale.providers=HOST
Reviewed-by: joehw
This commit is contained in:
parent
f9c9bf03a8
commit
74b79c6e19
4 changed files with 54 additions and 3 deletions
|
@ -75,7 +75,7 @@ public class HostLocaleProviderAdapterImpl {
|
|||
|
||||
// CalendarData value types
|
||||
private static final int CD_FIRSTDAYOFWEEK = 0;
|
||||
private static final int CD_MINIMALDAYSINFIRSTWEEK = 1;
|
||||
private static final int CD_FIRSTWEEKOFYEAR = 1;
|
||||
|
||||
// Currency/Locale display name types
|
||||
private static final int DN_CURRENCY_NAME = 0;
|
||||
|
@ -366,7 +366,15 @@ public class HostLocaleProviderAdapterImpl {
|
|||
|
||||
@Override
|
||||
public int getMinimalDaysInFirstWeek(Locale locale) {
|
||||
return 0;
|
||||
int firstWeek = getCalendarDataValue(
|
||||
removeExtensions(locale).toLanguageTag(),
|
||||
CD_FIRSTWEEKOFYEAR);
|
||||
// Interpret the value from Windows LOCALE_IFIRSTWEEKOFYEAR setting
|
||||
return switch (firstWeek) {
|
||||
case 1 -> 7; // First full week following 1/1 is the first week of the year.
|
||||
case 2 -> 4; // First week containing at least four days is the first week of the year.
|
||||
default -> 1; // First week can be a single day, if 1/1 falls on the last day of the week.
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -647,6 +647,11 @@ JNIEXPORT jint JNICALL Java_sun_util_locale_provider_HostLocaleProviderAdapterIm
|
|||
LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
|
||||
(LPWSTR)&num, sizeof(num));
|
||||
break;
|
||||
case sun_util_locale_provider_HostLocaleProviderAdapterImpl_CD_FIRSTWEEKOFYEAR:
|
||||
got = getLocaleInfoWrapper(langtag,
|
||||
LOCALE_IFIRSTWEEKOFYEAR | LOCALE_RETURN_NUMBER,
|
||||
(LPWSTR)&num, sizeof(num));
|
||||
break;
|
||||
}
|
||||
|
||||
(*env)->ReleaseStringChars(env, jlangtag, langtag);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue