本文整理汇总了Java中sun.util.locale.provider.CalendarDataUtility.retrieveFirstDayOfWeek方法的典型用法代码示例。如果您正苦于以下问题:Java CalendarDataUtility.retrieveFirstDayOfWeek方法的具体用法?Java CalendarDataUtility.retrieveFirstDayOfWeek怎么用?Java CalendarDataUtility.retrieveFirstDayOfWeek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.util.locale.provider.CalendarDataUtility
的用法示例。
在下文中一共展示了CalendarDataUtility.retrieveFirstDayOfWeek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setWeekCountData
import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
/**
* Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent.
* They are used to figure out the week count for a specific date for
* a given locale. These must be set when a Calendar is constructed.
* @param desiredLocale the given locale.
*/
private void setWeekCountData(Locale desiredLocale)
{
/* try to get the Locale data from the cache */
int[] data = cachedLocaleData.get(desiredLocale);
if (data == null) { /* cache miss */
data = new int[2];
data[0] = CalendarDataUtility.retrieveFirstDayOfWeek(desiredLocale);
data[1] = CalendarDataUtility.retrieveMinimalDaysInFirstWeek(desiredLocale);
cachedLocaleData.putIfAbsent(desiredLocale, data);
}
firstDayOfWeek = data[0];
minimalDaysInFirstWeek = data[1];
}
示例2: of
import sun.util.locale.provider.CalendarDataUtility; //导入方法依赖的package包/类
/**
* Obtains an instance of {@code WeekFields} appropriate for a locale.
* <p>
* This will look up appropriate values from the provider of localization data.
*
* @param locale the locale to use, not null
* @return the week-definition, not null
*/
public static WeekFields of(Locale locale) {
Objects.requireNonNull(locale, "locale");
locale = new Locale(locale.getLanguage(), locale.getCountry()); // elminate variants
int calDow = CalendarDataUtility.retrieveFirstDayOfWeek(locale);
DayOfWeek dow = DayOfWeek.SUNDAY.plus(calDow - 1);
int minDays = CalendarDataUtility.retrieveMinimalDaysInFirstWeek(locale);
return WeekFields.of(dow, minDays);
}