Enum Class Weekday
- All Implemented Interfaces:
Serializable
,Comparable<Weekday>
,java.lang.constant.Constable
,TemporalAccessor
,Function<PlainDate,PlainDate>
,Predicate<GregorianDate>
,UnaryOperator<PlainDate>
,ChronoCondition<GregorianDate>
,ChronoOperator<PlainDate>
,ThreetenAdapter
Enumeration of weekdays.
Several methods with a Weekmodel
-parameter support other
week models, too.
- Author:
- Meno Hochschild
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionFriday with the numerical ISO-value5
.Monday with the numerical ISO-value1
.Saturday with the numerical ISO-value6
.Sunday with the numerical ISO-value7
.Thursday with the numerical ISO-value4
.Tuesday with the numerical ISO-value2
.Wednesday with the numerical ISO-value3
. -
Method Summary
Modifier and TypeMethodDescriptionAdjusts given entity and yields a changed copy of argument.static Weekday
Conversion from thejava.time
-equivalent.getDisplayName(Locale locale)
Equivalent to the expressiongetDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT)
.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
Gets the numerical value corresponding to the rule of given week model on which day a week starts.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.previous()
Rolls to the previous day of week.roll(int days)
Rolls this day of week by given amount of days.boolean
test(GregorianDate context)
Decides if given context matches this condition.Conversion to thejava.time
-equivalent.static Weekday
valueOf(int dayOfWeek)
Gets the enum-constant which corresponds to the given numerical value.static Weekday
Gets the weekday corresponding to given gregorian date.static Weekday
Gets the enum-constant which corresponds to the given localized numerical value taking into account given week model.static Weekday
Returns the enum constant of this class with the specified name.static Weekday[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.static Weekday[]
Yields an array which is sorted corresponding to the rule of given week model on which day a week starts.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
Methods inherited from interface net.time4j.engine.ThreetenAdapter
get, getLong, isSupported, query, range
-
Enum Constant Details
-
MONDAY
Monday with the numerical ISO-value1
. -
TUESDAY
Tuesday with the numerical ISO-value2
. -
WEDNESDAY
Wednesday with the numerical ISO-value3
. -
THURSDAY
Thursday with the numerical ISO-value4
. -
FRIDAY
Friday with the numerical ISO-value5
. -
SATURDAY
Saturday with the numerical ISO-value6
. -
SUNDAY
Sunday with the numerical ISO-value7
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getValue
public int getValue()Gets the corresponding numerical ISO-value.
- Returns:
monday=1, tuesday=2, wednesday=3, thursday=4, friday=5, saturday=6, sunday=7
- See Also:
valueOf(int)
,Weekmodel.ISO
-
getValue
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
forWeekmodel.of(Locale.US)
(instead of the ISO-value7
).- Parameters:
model
- localized week model- Returns:
- localized weekday number (1 - 7)
- See Also:
Weekmodel.getFirstDayOfWeek()
,values(Weekmodel)
,valueOf(int, Weekmodel)
-
values
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.
- Parameters:
model
- localized week model- Returns:
- new weekday array
- See Also:
Weekmodel.getFirstDayOfWeek()
,getValue(Weekmodel)
,valueOf(int, Weekmodel)
-
valueOf
Gets the enum-constant which corresponds to the given numerical value.
- Parameters:
dayOfWeek
- (monday=1, tuesday=2, wednesday=3, thursday=4, friday=5, saturday=6, sunday=7)- Returns:
- weekday as enum
- Throws:
IllegalArgumentException
- if the argument is out of range- See Also:
getValue()
,Weekmodel.ISO
-
valueOf
Gets the enum-constant which corresponds to the given localized numerical value taking into account given week model.
- Parameters:
dayOfWeek
- localized weekday number (1 - 7)model
- localized week model- Returns:
- weekday as enum
- Throws:
IllegalArgumentException
- if the int-argument is out of range- See Also:
Weekmodel.getFirstDayOfWeek()
,values(Weekmodel)
,getValue(Weekmodel)
-
valueOf
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.
- Parameters:
year
- proleptic iso yearmonthOfYear
- gregorian monthdayOfMonth
- day of month (1 - 31)- Returns:
- weekday
- Throws:
IllegalArgumentException
- if the day is out of range
-
next
Rolls to the next day of week.
The result is Monday if this method is applied on Sunday.
- Returns:
- next weekday
-
previous
Rolls to the previous day of week.
The result is Sunday if this method is applied on Monday.
- Returns:
- previous weekday
-
roll
Rolls this day of week by given amount of days.
- Parameters:
days
- count of days (maybe negative)- Returns:
- result of rolling operation
-
getDisplayName
Equivalent to the expression
getDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT)
.- Parameters:
locale
- language setting- Returns:
- descriptive text (long form, never
null
) - See Also:
getDisplayName(Locale, TextWidth, OutputContext)
-
getDisplayName
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).
- Parameters:
locale
- language settingwidth
- text widthcontext
- output context- Returns:
- descriptive text for given locale and style (never
null
)
-
parse
public static Weekday parse(CharSequence text, Locale locale, TextWidth width, OutputContext context) throws ParseExceptionTries to interprete given text as day-of-week.
- Parameters:
text
- the text to be parsedlocale
- language settingwidth
- expected text widthcontext
- expected output context- Returns:
- the parsed day of week if successful
- Throws:
ParseException
- if parsing fails- Since:
- 3.33/4.28
- See Also:
getDisplayName(Locale, TextWidth, OutputContext)
-
test
Description copied from interface:ChronoCondition
Decides 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
- Specified by:
test
in interfaceChronoCondition<GregorianDate>
- Specified by:
test
in interfacePredicate<GregorianDate>
- Parameters:
context
- context as base of testing this condition- Returns:
true
if given time context matches this condition elsefalse
-
toTemporalAccessor
Conversion to the
java.time
-equivalent.- Specified by:
toTemporalAccessor
in interfaceThreetenAdapter
- Returns:
- DayOfWeek
- Since:
- 4.28
- See Also:
from(DayOfWeek)
-
from
Conversion from the
java.time
-equivalent.- Parameters:
dayOfWeek
- the day of week to be converted- Returns:
- Weekday
- Since:
- 4.28
- See Also:
toTemporalAccessor()
-
apply
Description copied from interface:ChronoOperator
Adjusts given entity and yields a changed copy of argument.
Will be called by
ChronoEntity.with(ChronoOperator)
.
-