gpt4 book ai didi

java - Java中getMinimalDaysInFirstWeek方法的默认返回值是多少?

转载 作者:行者123 更新时间:2023-11-30 09:35:58 25 4
gpt4 key购买 nike

我搜索了但无法在 java 的 Calender 类中找到 getMinimalDaysInFirstWeek() 的默认值。我没有设置语言环境等任何内容。我想知道第一周的默认最少天数是多少。不幸的是,我无法运行代码并检查自己,因为它在我有权阅读的服务器上。

最佳答案

Calendar.getInstance() ,返回 GregorianCalendar (通常)构造 Calendar使用默认语言环境的对象:

protected Calendar()
{
this(TimeZone.getDefaultRef(), Locale.getDefault());
sharedZone = true;
}

然后执行下面的代码:

private void setWeekCountData(Locale desiredLocale)
{
/* try to get the Locale data from the cache */
int[] data = cachedLocaleData.get(desiredLocale);
if (data == null) { /* cache miss */
ResourceBundle bundle = LocaleData.getCalendarData(desiredLocale);
data = new int[2];
data[0] = Integer.parseInt(bundle.getString("firstDayOfWeek"));
data[1] = Integer.parseInt(bundle.getString("minimalDaysInFirstWeek"));
cachedLocaleData.putIfAbsent(desiredLocale, data);
}
firstDayOfWeek = data[0];
minimalDaysInFirstWeek = data[1];
}

所以 - minimalDaysInFirstWeek从包 sun.util.resources 的已编译资源包中检索, 来自 CalendarData_<locale>.class (在 Oracle JVM 上)。

例如,对于波兰语语言环境,我们有:

public final class CalendarData_pl extends LocaleNamesBundle
{
protected final Object[][] getContents()
{
return new Object[][] { { "firstDayOfWeek", "2" }, { "minimalDaysInFirstWeek", "4" } };
}
}

关于java - Java中getMinimalDaysInFirstWeek方法的默认返回值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11028764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com