public final class Weekmodel extends Object implements Serializable
Defines rules for the localized handling of weekdays and calendar weeks on the base of a seven-day-week.
Furthermore, a Weekmodel contains some week-related elements
which can be used in all types containing an ISO-8601-date
(PlainTimestamp and PlainDate).
WeekdataProvider,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static Weekmodel |
ISO
Standard week rules as defined by ISO-8601.
|
| Modifier and Type | Method and Description |
|---|---|
AdjustableElement<Integer,PlainDate> |
boundedWeekOfMonth()
Defines an element for the week of month with a localized week number,
constrained to the current calendar month.
|
AdjustableElement<Integer,PlainDate> |
boundedWeekOfYear()
Defines an element for the week of year with a localized week number,
constrained to the current calendar year.
|
boolean |
equals(Object obj)
Compares on the base of internal week rules.
|
Weekday |
getEndOfWeekend()
Defines the last day of weekend.
|
Weekday |
getFirstDayOfWeek()
Defines the first day of the calendar week in this model.
|
Weekday |
getFirstWorkday()
Gets the first working day as first day after end of weekend.
|
int |
getMinimalDaysInFirstWeek()
Defines the minimum count of days the first calendar week of year
(or month) must contain.
|
Weekday |
getStartOfWeekend()
Defines the first day of the weekend.
|
int |
hashCode()
Defines the hash value.
|
NavigableElement<Weekday> |
localDayOfWeek()
Defines an element for the weekday with a localized day number in
the value range
1-7. |
static Weekmodel |
of(Locale locale)
Gets a suitable weekmodel for the given country.
|
static Weekmodel |
of(Weekday firstDayOfWeek,
int minimalDaysInFirstWeek)
Creates a new week model with the given rules and the
weekend-definition Saturday/Sunday.
|
static Weekmodel |
of(Weekday firstDayOfWeek,
int minimalDaysInFirstWeek,
Weekday startOfWeekend,
Weekday endOfWeekend)
Creates a new week model with the given rules.
|
static Weekmodel |
ofSystem()
Gets a suitable weekmodel for the default locale of system.
|
String |
toString()
Debugging-support.
|
ChronoCondition<GregorianDate> |
weekend()
Defines a chronological condition if a date matches a weekend.
|
AdjustableElement<Integer,PlainDate> |
weekOfMonth()
Defines an element for the calendar week of month with a localized
week number.
|
AdjustableElement<Integer,PlainDate> |
weekOfYear()
Defines an element for the calendar week of year with a localized
week number.
|
public static final Weekmodel ISO
Standard week rules as defined by ISO-8601.
Monday is considered as first day of calendar week. And the first calendar week of year must contain at least four days respective contain the first Thursday of year. Saturday and Sunday are considered as weekend.
public static Weekmodel of(Weekday firstDayOfWeek, int minimalDaysInFirstWeek)
Creates a new week model with the given rules and the weekend-definition Saturday/Sunday.
firstDayOfWeek - localized first day of weekminimalDaysInFirstWeek - required minimum count of days for
the first week of year in range (1-7)IllegalArgumentException - if any argument is out of rangeof(Locale)public static Weekmodel of(Weekday firstDayOfWeek, int minimalDaysInFirstWeek, Weekday startOfWeekend, Weekday endOfWeekend)
Creates a new week model with the given rules.
firstDayOfWeek - localized first day of weekminimalDaysInFirstWeek - required minimum count of days for
the first week of year in range (1-7)startOfWeekend - first day of weekendendOfWeekend - last day of weekendIllegalArgumentException - if any argument is out of rangeof(Locale)public static Weekmodel ofSystem()
Gets a suitable weekmodel for the default locale of system.
Note: In order to get a weekend definition deviating from the standard Saturday + Sunday, the i18n-module must be present in classpath since v2.2.
Locale.getDefault()public static Weekmodel of(Locale locale)
Gets a suitable weekmodel for the given country.
Note: In order to get a weekend definition deviating from the
standard Saturday + Sunday, the i18n-module must be present in
classpath since v2.2. If the country-part of given locale is missing
then this method will just return ISO.
locale - country settingpublic Weekday getFirstDayOfWeek()
Defines the first day of the calendar week in this model.
The first day of week is not required to be identical with the first working day. It rather marks the the first column a graphical localized calendar. However, in ISO-8601 the first day of week and the first working day (equal to first day after weekend) are identical.
getFirstWorkday()public int getMinimalDaysInFirstWeek()
Defines the minimum count of days the first calendar week of year (or month) must contain.
If this method yields 1 then the first calendar week of
year always contains the first of January. If the return value is
7 instead then only the first full seven-day-week is the
first calendar week of year. In ISO-8601 the value is 4.
public Weekday getStartOfWeekend()
Defines the first day of the weekend.
In ISO-8601 Saturday is considered as start of weekend (note: not explicitly mentioned in ISO-paper).
public Weekday getEndOfWeekend()
Defines the last day of weekend.
In ISO-8601 Sunday is considered as end of weekend (note: not explicitly mentioned in ISO-paper).
public Weekday getFirstWorkday()
Gets the first working day as first day after end of weekend.
Note: The last working day of week is not well defined however and needs to be defined by the application itself. For example Saturday is considered as start of weekend but also handled as legal working day in most countries.
@FormattableElement(format="w") public AdjustableElement<Integer,PlainDate> weekOfYear()
Defines an element for the calendar week of year with a localized week number.
In ISO-8601 the value range is given by 1-52/53. Reference
year is the week-based year, not the calendar year. Therefore the
maximum of this element is equivalent to the last calendar week of the
week-based year. Examples:
PlainDate date1 = PlainDate.of(2012, 12, 31); // Monday System.out.println(date1.get(Weekmodel.ISO.weekOfYear())); // Output: 1 (first calendar week of year 2013) PlainDate date2 = PlainDate.of(2000, 1, 2); // Sunday System.out.println(date2.get(Weekmodel.ISO.weekOfYear())); // Output: 52 (last calendar week of year 1999)
Note: This element uses the lenient mode if new values are to be set
(isLenient() == true).
@FormattableElement(format="W") public AdjustableElement<Integer,PlainDate> weekOfMonth()
Defines an element for the calendar week of month with a localized week number.
In ISO-8601 the value range is given by 1-4/5. The behaviour
is fully conform to the week of year - like in CLDR standard.
Note: This element uses the lenient mode if new values are to be set
(isLenient() == true).
weekOfYear()@FormattableElement(format="e", standalone="c") public NavigableElement<Weekday> localDayOfWeek()
Defines an element for the weekday with a localized day number in
the value range 1-7.
This element defines localized weekday numbers in numerical formatting
and also a localized sorting order of weekdays, but still manages values
of type Weekday. However, the value range with its minimum and
maximum is localized, too, i.e. the element defines as minium the value
getFirstDayOfWeek().
In contrast the element PlainDate.DAY_OF_WEEK defines a
strict ISO-8601-conforming order and ISO-weekday-numbers.
public AdjustableElement<Integer,PlainDate> boundedWeekOfYear()
Defines an element for the week of year with a localized week number, constrained to the current calendar year.
In ISO-8601-calendars the value range is 0/1-52/53, in other
weekmodels the maximum value can also be 54. In contrast to
weekOfYear() this week can be shortened (less than seven days)
at the start or end of a calendar year. If the week normally belongs
to the previous year or to the following year then the bounded week
gets the value 0 resp. for the end of year the incremented
maximum value. This behaviour is a simplifying deviation from
CLDR-standard.
Note: This element uses the lenient mode if new values are to be set
(isLenient() == true).
public AdjustableElement<Integer,PlainDate> boundedWeekOfMonth()
Defines an element for the week of month with a localized week number, constrained to the current calendar month.
In ISO-8601-calendars the value range is 0/1-4/5, in other
weekmodels the maximum value can also be 6. In contrast to
weekOfMonth() this week can be shortened (less than seven days)
at the start or end of a calendar month. If the week normally belongs
to the previous month or to the following month then the bounded week
gets the value 0 resp. for the end of month the incremented
maximum value. This behaviour is a simplifying deviation from
CLDR-standard but is the same as defined in the JDK.
Note: This element uses the lenient mode if new values are to be set
(isLenient() == true).
boundedWeekOfYear()public ChronoCondition<GregorianDate> weekend()
Defines a chronological condition if a date matches a weekend.
Example:
PlainDate date = new PlainDate(2013, 3, 30); // Saturday
System.out.println(date.matches(Weekmodel.ISO.weekend()));
// Output: true
Locale yemen = new Locale("ar", "YE");
System.out.println(date.matches(Weekmodel.of(yemen).weekend()));
// Output: false (in Yemen the weekend matches Thursday and Friday)
public boolean equals(Object obj)
Compares on the base of internal week rules.
Copyright © 2014–2015. All rights reserved.