Java Code Examples for java.time.DayOfWeek#toString()

The following examples show how to use java.time.DayOfWeek#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
public Object eval(DayOfWeek dayOfWeek, Boolean asString) {
	if (dayOfWeek == null) {
		return null;
	}
	if (asString) {
		return dayOfWeek.toString();
	}
	return dayOfWeek;
}
 
Example 2
Source File: StringColumnDayOfWeekMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public String toNonNullValue(DayOfWeek value) {
    return value.toString();
}
 
Example 3
Source File: WeekFields.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: WeekFields.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: WeekFields.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 6
Source File: WeekFields.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: WeekFields.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 8
Source File: WeekFields.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 9
Source File: WeekFields.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: WeekFields.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 11
Source File: WeekFields.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: WeekFields.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 13
Source File: WeekFields.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * 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 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;
}
 
Example 14
Source File: WeekFields.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 15
Source File: WeekFields.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 16
Source File: WeekFields.java    From desugar_jdk_libs with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 17
Source File: WeekFields.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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;
}
 
Example 18
Source File: WeekFields.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source File: WeekFields.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: WeekFields.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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;
}