public enum DayOfWeek extends java.lang.Enum<DayOfWeek>
DayOfWeek is an enum representing the 7 days of the week -
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday.
In addition to the textual enum name, each day-of-week has an int value.
The int value from 1 (Sunday) to 7 (Saturday).
It is recommended that applications use the enum rather than the int value
to ensure code clarity.
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.
| Enum Constant and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
static DayOfWeek |
getDayOfWeek(int value)
Obtains an instance of
DayOfWeek from an int value. |
static DayOfWeek |
getDayOfWeek(java.lang.String name)
Obtains an instance of
DayOfWeek from an String value. |
java.lang.String |
getName()
Gets the textual representation, such as 'Monday' or 'Friday'.
|
java.lang.String |
getShortName()
Gets the textual representation, such as 'Mon' or 'Fri'.
|
int |
getValue()
Gets the day-of-week
int value. |
DayOfWeek |
minus(long days)
returns the day-of-week that is the specified number of days before this one
|
DayOfWeek |
plus(long days)
Returns the day-of-week that is the specified number of days after this one.
|
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.
|
public static final DayOfWeek Sunday
1.public static final DayOfWeek Monday
2.public static final DayOfWeek Tuesday
3.public static final DayOfWeek Wednesday
4.public static final DayOfWeek Thursday
5.public static final DayOfWeek Friday
6.public static final DayOfWeek Saturday
7.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 namejava.lang.NullPointerException - if the argument is nullpublic int getValue()
int value.
The values are numbered from 1 (Sunday) to 7 (Saturday).
public java.lang.String getName()
This returns the textual name used to identify the day-of-week, suitable for presentation to the user.
public java.lang.String getShortName()
This returns the short textual name used to identify the day-of-week, suitable for presentation to the user.
public DayOfWeek minus(long days)
days - public DayOfWeek plus(long days)
The calculation rolls around the end of the week from Saturday to Sunday. The specified period may be negative.
This instance is immutable and unaffected by this method call.
days - the days to add, positive or negativepublic static DayOfWeek getDayOfWeek(int value)
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 from 1 (Sunday) to 7 (Saturday).
dayOfWeek - the day-of-week to represent, from 1 (Sunday) to 7 (Saturday)public static DayOfWeek getDayOfWeek(java.lang.String name)
DayOfWeek from an String value.
DayOfWeek is an enum representing the 7 days of the week.
This factory allows the enum to be obtained from the String value.
The String value from "Sunday" or "Sun" (Sunday) to "Saturday" or "Sat" (Saturday).
dayOfWeek - the day-of-week to represent, from "Sunday" or "Sun" (Sunday) to "Saturday" or "Sat" (Saturday)