本文整理匯總了Java中java.time.DayOfWeek.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java DayOfWeek.toString方法的具體用法?Java DayOfWeek.toString怎麽用?Java DayOfWeek.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.DayOfWeek
的用法示例。
在下文中一共展示了DayOfWeek.toString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: of
import java.time.DayOfWeek; //導入方法依賴的package包/類
/**
* Obtains an instance of {@code WeekDefinition} from the first day-of-week and minimal days.
* <p>
* The first day-of-week defines the ISO {@code DayOfWeek} that is day 1 of the week. The minimal number of
* days in the first week defines how many days must be present in a month or year, starting from the first
* day-of-week, before the week is counted as the first week. A value of 1 will count the first day of the
* month or year as part of the first week, whereas a value of 7 will require the whole seven days to be in
* the new month or year.
*
* @param firstDayOfWeek the first day of the week, not null
* @param minimalDaysInFirstWeek the minimal number of days in the first week, from 1 to 7
* @return the week-definition, not null
* @throws IllegalArgumentException if the minimal days value is invalid
*/
public static WeekDefinition of(DayOfWeek firstDayOfWeek, int minimalDaysInFirstWeek) {
if (firstDayOfWeek == DayOfWeek.MONDAY && minimalDaysInFirstWeek == 4) {
return ISO;
}
String key = firstDayOfWeek.toString() + minimalDaysInFirstWeek;
WeekDefinition rules = CACHE.get(key);
if (rules == null) {
rules = new WeekDefinition(firstDayOfWeek, minimalDaysInFirstWeek);
CACHE.putIfAbsent(key, rules);
rules = CACHE.get(key);
}
return rules;
}
示例2: of
import java.time.DayOfWeek; //導入方法依賴的package包/類
/**
* Obtains an instance of {@code WeekFields} from the first day-of-week and minimal days.
* <p>
* The first day-of-week defines the ISO {@code DayOfWeek} that is day 1 of the week.
* The minimal number of days in the first week defines how many days must be present
* in a month or year, starting from the first day-of-week, before the week is counted
* as the first week. A value of 1 will count the first day of the month or year as part
* of the first week, whereas a value of 7 will require the whole seven days to be in
* the new month or year.
* <p>
* WeekFields instances are singletons; for each unique combination
* of {@code firstDayOfWeek} and {@code minimalDaysInFirstWeek} the
* the same instance will be returned.
*
* @param firstDayOfWeek the first day of the week, not null
* @param minimalDaysInFirstWeek the minimal number of days in the first week, from 1 to 7
* @return the week-definition, not null
* @throws IllegalArgumentException if the minimal days value is less than one
* or greater than 7
*/
public static WeekFields of(DayOfWeek firstDayOfWeek, int minimalDaysInFirstWeek) {
String key = firstDayOfWeek.toString() + minimalDaysInFirstWeek;
WeekFields rules = CACHE.get(key);
if (rules == null) {
rules = new WeekFields(firstDayOfWeek, minimalDaysInFirstWeek);
CACHE.putIfAbsent(key, rules);
rules = CACHE.get(key);
}
return rules;
}