public enum Weekday extends Enum<Weekday> implements ChronoCondition<GregorianDate>
Enumeration of weekdays.
Several methods with a Weekmodel-parameter support other
week models, too.
| Enum Constant and Description |
|---|
FRIDAY
Friday with the numerical ISO-value
5. |
MONDAY
Monday with the numerical ISO-value
1. |
SATURDAY
Saturday with the numerical ISO-value
6. |
SUNDAY
Sunday with the numerical ISO-value
7. |
THURSDAY
Thursday with the numerical ISO-value
4. |
TUESDAY
Tuesday with the numerical ISO-value
2. |
WEDNESDAY
Wednesday with the numerical ISO-value
3. |
| Modifier and Type | Method and Description |
|---|---|
static Weekday |
from(DayOfWeek dayOfWeek)
Conversion from the
java.time-equivalent. |
String |
getDisplayName(Locale locale)
Equivalent to the expression
getDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT). |
String |
getDisplayName(Locale locale,
TextWidth width,
OutputContext context)
Gets the description text dependent on the locale and style
parameters.
|
int |
getValue()
Gets the corresponding numerical ISO-value.
|
int |
getValue(Weekmodel model)
Gets the numerical value corresponding to the rule of given
week model on which day a week starts.
|
Weekday |
next()
Rolls to the next day of week.
|
static Weekday |
parse(CharSequence text,
Locale locale,
TextWidth width,
OutputContext context)
Tries to interprete given text as day-of-week.
|
Weekday |
previous()
Rolls to the previous day of week.
|
Weekday |
roll(int days)
Rolls this day of week by given amount of days.
|
boolean |
test(GregorianDate context)
Decides if given context matches this condition.
|
DayOfWeek |
toTemporalAccessor()
Conversion to the
java.time-equivalent. |
static Weekday |
valueOf(int dayOfWeek)
Gets the enum-constant which corresponds to the given numerical
value.
|
static Weekday |
valueOf(int year,
Month monthOfYear,
int dayOfMonth)
Gets the weekday corresponding to given gregorian date.
|
static Weekday |
valueOf(int dayOfWeek,
Weekmodel model)
Gets the enum-constant which corresponds to the given localized
numerical value taking into account given week model.
|
static Weekday |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Weekday[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
static Weekday[] |
values(Weekmodel model)
Yields an array which is sorted corresponding to the rule of given
week model on which day a week starts.
|
public static final Weekday MONDAY
1.public static final Weekday TUESDAY
2.public static final Weekday WEDNESDAY
3.public static final Weekday THURSDAY
4.public static final Weekday FRIDAY
5.public static final Weekday SATURDAY
6.public static final Weekday SUNDAY
7.public static Weekday[] values()
for (Weekday c : Weekday.values()) System.out.println(c);
public static Weekday valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic int getValue()
Gets the corresponding numerical ISO-value.
monday=1, tuesday=2, wednesday=3, thursday=4, friday=5, saturday=6, sunday=7valueOf(int),
Weekmodel.ISOpublic int getValue(Weekmodel model)
Gets the numerical value corresponding to the rule of given week model on which day a week starts.
In US, the rule is applied that weeks start with Sunday. If so then
this method will yield 1 for Weekmodel.of(Locale.US)
(instead of the ISO-value 7).
model - localized week modelWeekmodel.getFirstDayOfWeek(),
values(Weekmodel),
valueOf(int, Weekmodel)public static Weekday[] values(Weekmodel model)
Yields an array which is sorted corresponding to the rule of given week model on which day a week starts.
The alternative method generated by compiler without any parameters creates an array sorted according to ISO-8601-standard. This method is an overloaded variation where sorting is adjusted.
model - localized week modelWeekmodel.getFirstDayOfWeek(),
getValue(Weekmodel),
valueOf(int, Weekmodel)public static Weekday valueOf(int dayOfWeek)
Gets the enum-constant which corresponds to the given numerical value.
dayOfWeek - (monday=1, tuesday=2, wednesday=3, thursday=4,
friday=5, saturday=6, sunday=7)IllegalArgumentException - if the argument is out of rangegetValue(),
Weekmodel.ISOpublic static Weekday valueOf(int dayOfWeek, Weekmodel model)
Gets the enum-constant which corresponds to the given localized numerical value taking into account given week model.
dayOfWeek - localized weekday number (1 - 7)model - localized week modelIllegalArgumentException - if the int-argument is out of rangeWeekmodel.getFirstDayOfWeek(),
values(Weekmodel),
getValue(Weekmodel)public static Weekday valueOf(int year, Month monthOfYear, int dayOfMonth)
Gets the weekday corresponding to given gregorian date.
The proleptic gregorian calendar as defined in ISO-8601 is the calculation basis. That means the current leap year rule is even applied for dates before the introduction of gregorian calendar.
year - proleptic iso yearmonthOfYear - gregorian monthdayOfMonth - day of month (1 - 31)IllegalArgumentException - if the day is out of rangepublic Weekday next()
Rolls to the next day of week.
The result is Monday if this method is applied on Sunday.
public Weekday previous()
Rolls to the previous day of week.
The result is Sunday if this method is applied on Monday.
public Weekday roll(int days)
Rolls this day of week by given amount of days.
days - count of days (maybe negative)public String getDisplayName(Locale locale)
Equivalent to the expression
getDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT).
locale - language settingnull)getDisplayName(Locale, TextWidth, OutputContext)public String getDisplayName(Locale locale, TextWidth width, OutputContext context)
Gets the description text dependent on the locale and style parameters.
The second argument controls the width of description while the third argument is only relevant for languages which make a difference between stand-alone forms and embedded text forms (does not matter in English).
locale - language settingwidth - text widthcontext - output contextnull)public static Weekday parse(CharSequence text, Locale locale, TextWidth width, OutputContext context) throws ParseException
Tries to interprete given text as day-of-week.
text - the text to be parsedlocale - language settingwidth - expected text widthcontext - expected output contextParseException - if parsing failsgetDisplayName(Locale, TextWidth, OutputContext)public boolean test(GregorianDate context)
ChronoConditionDecides if given context matches this condition.
Due to better readability it is recommended to use following equivalent approach instead of this method::
import static net.time4j.Weekday.SATURDAY; import static net.time4j.Month.JANUARY; PlainDate date = PlainDate.of(2014, JANUARY, 25); System.out.println(SATURDAY.test(date)); // direct use System.out.println(date.matches(SATURDAY)); // recommended callback
test in interface Predicate<GregorianDate>test in interface ChronoCondition<GregorianDate>context - context as base of testing this conditiontrue if given time context matches this condition
else falsepublic DayOfWeek toTemporalAccessor()
Conversion to the java.time-equivalent.
from(DayOfWeek)public static Weekday from(DayOfWeek dayOfWeek)
Conversion from the java.time-equivalent.
dayOfWeek - the day of week to be convertedtoTemporalAccessor()Copyright © 2014–2017. All rights reserved.