|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Object java.lang.Enum<DayOfWeek> javax.time.calendar.DayOfWeek
public enum DayOfWeek
A day-of-week, such as 'Tuesday'.
DayOfWeek
is an enum representing the 7 days of the week -
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
The calendrical framework requires date-time fields to have an int
value.
The int
value follows the ISO-8601 standard, from 1 (Monday) to 7 (Sunday).
It is recommended that applications use the enum rather than the int
value
to ensure code clarity.
This enum provides access to the localized textual form of the day-of-week.
However, some countries assign different numeric values to the days, such as Sunday = 1.
Applications requiring such a localized numbering scheme should use WeekRules
.
Do not use ordinal()
to obtain the numeric representation of DayOfWeek
.
Use getValue()
instead.
This enum represents a common concept that is found in many calendar systems. As such, this enum may be used by any calendar system that has the day-of-week concept defined exactly equivalent to the ISO calendar system.
This is an immutable and thread-safe enum.
Enum Constant Summary | |
---|---|
FRIDAY
The singleton instance for the day-of-week of Friday. |
|
MONDAY
The singleton instance for the day-of-week of Monday. |
|
SATURDAY
The singleton instance for the day-of-week of Saturday. |
|
SUNDAY
The singleton instance for the day-of-week of Sunday. |
|
THURSDAY
The singleton instance for the day-of-week of Thursday. |
|
TUESDAY
The singleton instance for the day-of-week of Tuesday. |
|
WEDNESDAY
The singleton instance for the day-of-week of Wednesday. |
Method Summary | ||
---|---|---|
static DayOfWeek |
from(Calendrical... calendricals)
Obtains an instance of DayOfWeek from a set of calendricals. |
|
|
get(CalendricalRule<T> ruleToDerive)
Gets the value of the specified calendrical rule. |
|
java.lang.String |
getText(TextStyle style,
java.util.Locale locale)
Gets the textual representation, such as 'Mon' or 'Friday'. |
|
int |
getValue()
Gets the day-of-week int value. |
|
boolean |
matchesCalendrical(Calendrical calendrical)
Checks if the day-of-month extracted from the calendrical matches this. |
|
DayOfWeek |
next()
Gets the next day-of-week. |
|
static DayOfWeek |
of(int dayOfWeek)
Obtains an instance of DayOfWeek from an int value. |
|
DayOfWeek |
previous()
Gets the previous day-of-week. |
|
DayOfWeek |
roll(int days)
Rolls the day-of-week, adding the specified number of days. |
|
static CalendricalRule<DayOfWeek> |
rule()
Gets the rule for DayOfWeek . |
|
DateTimeField |
toField()
Converts this day-of-week to an equivalent field. |
|
static DayOfWeek |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
|
static DayOfWeek[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class java.lang.Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final DayOfWeek MONDAY
1
.
public static final DayOfWeek TUESDAY
2
.
public static final DayOfWeek WEDNESDAY
3
.
public static final DayOfWeek THURSDAY
4
.
public static final DayOfWeek FRIDAY
5
.
public static final DayOfWeek SATURDAY
6
.
public static final DayOfWeek SUNDAY
7
.
Method Detail |
---|
public static DayOfWeek[] values()
for (DayOfWeek c : DayOfWeek.values()) System.out.println(c);
public static DayOfWeek valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified name
java.lang.NullPointerException
- if the argument is nullpublic static CalendricalRule<DayOfWeek> rule()
DayOfWeek
.
This rule is a calendrical rule based on DayOfWeek
.
The equivalent date-time rule is ISODateTimeRule.DAY_OF_WEEK
.
public static DayOfWeek of(int dayOfWeek)
DayOfWeek
from an int
value.
DayOfWeek
is an enum representing the 7 days of the week.
This factory allows the enum to be obtained from the int
value.
The int
value follows the ISO-8601 standard, from 1 (Monday) to 7 (Sunday).
An exception is thrown if the value is invalid.
dayOfWeek
- the day-of-week to represent, from 1 (Monday) to 7 (Sunday)
IllegalCalendarFieldValueException
- if the day-of-week is invalidpublic static DayOfWeek from(Calendrical... calendricals)
DayOfWeek
from a set of calendricals.
A calendrical represents some form of date and time information. This method combines the input calendricals into a day-of-week.
calendricals
- the calendricals to create a day-of-week from, no nulls, not null
CalendricalException
- if unable to merge to a day-of-weekpublic <T> T get(CalendricalRule<T> ruleToDerive)
This will only return a value for the ISODateTimeRule.DAY_OF_WEEK
rule, or something derivable from it.
get
in interface Calendrical
ruleToDerive
- the rule to derive, not null
public int getValue()
int
value.
The values are numbered following the ISO-8601 standard, from 1 (Monday) to 7 (Sunday).
public java.lang.String getText(TextStyle style, java.util.Locale locale)
This enum uses the ISODateTimeRule.DAY_OF_WEEK
rule to obtain the text.
This allows the text to be localized by language, but not by chronology.
If no textual mapping is found then the numeric value
is returned.
locale
- the locale to use, not null
public DayOfWeek next()
This calculates based on the time-line, thus it rolls around the end of the week. The next day after Sunday is Monday.
public DayOfWeek previous()
This calculates based on the time-line, thus it rolls around the end of the week. The previous day before Monday is Sunday.
public DayOfWeek roll(int days)
This calculates based on the time-line, thus it rolls around the end of the week from Sunday to Monday. The days to roll by may be negative.
This instance is immutable and unaffected by this method call.
days
- the days to roll by, positive or negative
public boolean matchesCalendrical(Calendrical calendrical)
This method implements the CalendricalMatcher
interface.
It is intended that applications use LocalDate.matches(javax.time.calendar.CalendricalMatcher)
rather than this method.
matchesCalendrical
in interface CalendricalMatcher
calendrical
- the calendrical to match, not null
public DateTimeField toField()
The field is based on ISODateTimeRule.DAY_OF_WEEK
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |