DayOfWeek

A day-of-week, such as 'Tuesday'. !(p) {@code DayOfWeek} is an enum representing the 7 days of the week - Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. !(p) In addition to the textual enum name, each day-of-week has an {@code int} value. The {@code int} value follows the ISO-8601 standard, from 1 (Monday) to 7 (Sunday). It is recommended that applications use the enum rather than the {@code int} value to ensure code clarity. !(p) This enum provides access to the localized textual form of the day-of-week. Some locales also assign different numeric values to the days, declaring Sunday to have the value 1, however this class provides no support for this. See {@link WeekFields} for localized week-numbering. !(p) !(b)Do not use {@code ordinal()} to obtain the numeric representation of {@code DayOfWeek}. Use {@code getValue()} instead.</b> !(p) 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.

@implSpec This is an immutable and thread-safe enum.

@since 1.8

Members

Functions

adjustInto
Temporal adjustInto(Temporal temporal)

Adjusts the specified temporal object to have this day-of-week. !(p) This returns a temporal object of the same observable type as the input with the day-of-week changed to be the same as this. !(p) The adjustment is equivalent to using {@link Temporal#_with(TemporalField, long)} passing {@link ChronoField#DAY_OF_WEEK} as the field. Note that this adjusts forwards or backwards within a Monday to Sunday week. See {@link hunt.time.temporal.WeekFields#dayOfWeek()} for localized week start days. See {@code TemporalAdjuster} for other adjusters with more control, such as {@code next(MONDAY)}. !(p) In most cases, it is clearer to reverse the calling pattern by using {@link Temporal#_with(TemporalAdjuster)}: !(pre) // these two lines are equivalent, but the second approach is recommended temporal = thisDayOfWeek.adjustInto(temporal); temporal = temporal._with(thisDayOfWeek); </pre> !(p) For example, given a date that is a Wednesday, the following are output: !(pre) dateOnWed._with(MONDAY); // two days earlier dateOnWed._with(TUESDAY); // one day earlier dateOnWed._with(WEDNESDAY); // same date dateOnWed._with(THURSDAY); // one day later dateOnWed._with(FRIDAY); // two days later dateOnWed._with(SATURDAY); // three days later dateOnWed._with(SUNDAY); // four days later </pre> !(p) This instance is immutable and unaffected by this method call.

get
int get(TemporalField field)

Gets the value of the specified field from this day-of-week as an {@code int}. !(p) This queries this day-of-week for the value of the specified field. The returned value will always be within the valid range of values for the field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown. !(p) If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the value of the day-of-week, from 1 to 7, will be returned. All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. !(p) If the field is not a {@code ChronoField}, then the result of this method is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} passing {@code this} as the argument. Whether the value can be obtained, and what the value represents, is determined by the field.

getDisplayName
string getDisplayName(TextStyle style, Locale locale)

Gets the textual representation, such as 'Mon' or 'Friday'. !(p) This returns the textual name used to identify the day-of-week, suitable for presentation to the user. The parameters control the style of the returned text and the locale. !(p) If no textual mapping is found then the {@link #getValue() numeric value} is returned.

getLong
long getLong(TemporalField field)

Gets the value of the specified field from this day-of-week as a {@code long}. !(p) This queries this day-of-week for the value of the specified field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown. !(p) If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the value of the day-of-week, from 1 to 7, will be returned. All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. !(p) If the field is not a {@code ChronoField}, then the result of this method is obtained by invoking {@code TemporalField.getFrom(TemporalAccessor)} passing {@code this} as the argument. Whether the value can be obtained, and what the value represents, is determined by the field.

getValue
int getValue()

Gets the day-of-week {@code int} value. !(p) The values are numbered following the ISO-8601 standard, from 1 (Monday) to 7 (Sunday). See {@link hunt.time.temporal.WeekFields#dayOfWeek()} for localized week-numbering.

isSupported
bool isSupported(TemporalField field)

Checks if the specified field is supported. !(p) This checks if this day-of-week can be queried for the specified field. If false, then calling the {@link #range(TemporalField) range} and {@link #get(TemporalField) get} methods will throw an exception. !(p) If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then this method returns true. All other {@code ChronoField} instances will return false. !(p) If the field is not a {@code ChronoField}, then the result of this method is obtained by invoking {@code TemporalField.isSupportedBy(TemporalAccessor)} passing {@code this} as the argument. Whether the field is supported is determined by the field.

minus
DayOfWeek minus(long days)

Returns the day-of-week that is the specified number of days before this one. !(p) The calculation rolls around the start of the year from Monday to Sunday. The specified period may be negative. !(p) This instance is immutable and unaffected by this method call.

plus
DayOfWeek plus(long days)

Returns the day-of-week that is the specified number of days after this one. !(p) The calculation rolls around the end of the week from Sunday to Monday. The specified period may be negative. !(p) This instance is immutable and unaffected by this method call.

query
R query(TemporalQuery!(R) query)

Queries this day-of-week using the specified query. !(p) This queries this day-of-week using the specified query strategy object. The {@code TemporalQuery} object defines the logic to be used to obtain the result. Read the documentation of the query to understand what the result of this method will be. !(p) The result of this method is obtained by invoking the {@link TemporalQuery#queryFrom(TemporalAccessor)} method on the specified query passing {@code this} as the argument.

range
ValueRange range(TemporalField field)

Gets the range of valid values for the specified field. !(p) The range object expresses the minimum and maximum valid values for a field. This day-of-week is used to enhance the accuracy of the returned range. If it is not possible to return the range, because the field is not supported or for some other reason, an exception is thrown. !(p) If the field is {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} then the range of the day-of-week, from 1 to 7, will be returned. All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. !(p) If the field is not a {@code ChronoField}, then the result of this method is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)} passing {@code this} as the argument. Whether the range can be obtained is determined by the field.

range_super
ValueRange range_super(TemporalField field)
Undocumented in source. Be warned that the author may not have intended to support it.
super_get
int super_get(TemporalField field)
Undocumented in source. Be warned that the author may not have intended to support it.
super_query
R super_query(TemporalQuery!(R) query)
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

FRIDAY
DayOfWeek FRIDAY()

The singleton instance for the day-of-week of Friday. This has the numeric value of {@code 5}.

MONDAY
DayOfWeek MONDAY()

The singleton instance for the day-of-week of Monday. This has the numeric value of {@code 1}.

SATURDAY
DayOfWeek SATURDAY()

The singleton instance for the day-of-week of Saturday. This has the numeric value of {@code 6}.

SUNDAY
DayOfWeek SUNDAY()

The singleton instance for the day-of-week of Sunday. This has the numeric value of {@code 7}.

THURSDAY
DayOfWeek THURSDAY()

The singleton instance for the day-of-week of Thursday. This has the numeric value of {@code 4}.

TUESDAY
DayOfWeek TUESDAY()

The singleton instance for the day-of-week of Tuesday. This has the numeric value of {@code 2}.

WEDNESDAY
DayOfWeek WEDNESDAY()

The singleton instance for the day-of-week of Wednesday. This has the numeric value of {@code 3}.

from
DayOfWeek from(TemporalAccessor temporal)

Obtains an instance of {@code DayOfWeek} from a temporal object. !(p) This obtains a day-of-week based on the specified temporal. A {@code TemporalAccessor} represents an arbitrary set of date and time information, which this factory converts to an instance of {@code DayOfWeek}. !(p) The conversion extracts the {@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} field. !(p) This method matches the signature of the functional interface {@link TemporalQuery} allowing it to be used as a query via method reference, {@code DayOfWeek::from}.

of
DayOfWeek of(int dayOfWeek)

Obtains an instance of {@code DayOfWeek} from an {@code int} value. !(p) {@code DayOfWeek} is an enum representing the 7 days of the week. This factory allows the enum to be obtained from the {@code int} value. The {@code int} value follows the ISO-8601 standard, from 1 (Monday) to 7 (Sunday).

valueOf
DayOfWeek valueOf(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
values
DayOfWeek[] values()
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From TemporalAccessor

isSupported
bool isSupported(TemporalField field)

Checks if the specified field is supported. !(p) This checks if the date-time can be queried for the specified field. If false, then calling the {@link #range(TemporalField) range} and {@link #get(TemporalField) get} methods will throw an exception.

range
ValueRange range(TemporalField field)

Gets the range of valid values for the specified field. !(p) All fields can be expressed as a {@code long} integer. This method returns an object that describes the valid range for that value. The value of this temporal object is used to enhance the accuracy of the returned range. If the date-time cannot return the range, because the field is unsupported or for some other reason, an exception will be thrown. !(p) Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field.

get
int get(TemporalField field)

Gets the value of the specified field as an {@code int}. !(p) This queries the date-time for the value of the specified field. The returned value will always be within the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.

getLong
long getLong(TemporalField field)

Gets the value of the specified field as a {@code long}. !(p) This queries the date-time for the value of the specified field. The returned value may be outside the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.

query
R query(TemporalQuery!(R) query)

Queries this date-time. !(p) This queries this date-time using the specified query strategy object. !(p) Queries are a key tool for extracting information from date-times. They exists to externalize the process of querying, permitting different approaches, as per the strategy design pattern. Examples might be a query that checks if the date is the day before February 29th _in a leap year, or calculates the number of days to your next birthday. !(p) The most common query implementations are method references, such as {@code LocalDate::from} and {@code ZoneId::from}. Additional implementations are provided as static methods on {@link TemporalQuery}.

toString
string toString()
Undocumented in source.

From TemporalAdjuster

adjustInto
Temporal adjustInto(Temporal temporal)

Adjusts the specified temporal object. !(p) This adjusts the specified temporal object using the logic encapsulated _in the implementing class. Examples might be an adjuster that sets the date avoiding weekends, or one that sets the date to the last day of the month. !(p) There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use {@link Temporal#_with(TemporalAdjuster)}: !(pre) // these two lines are equivalent, but the second approach is recommended temporal = thisAdjuster.adjustInto(temporal); temporal = temporal._with(thisAdjuster); </pre> It is recommended to use the second approach, {@code _with(TemporalAdjuster)}, as it is a lot clearer to read _in code.

Meta