time
Class DayOfWeek

java.lang.Object
  extended by time.DayOfWeek

public final class DayOfWeek
extends java.lang.Object

Definition a day of the week.

Unlike month, this class is not an Enum, because DayOfWeek does not have a natural order. More precisely, even if everyone agrees on the order of weekdays, the first day of the week depends on the local usage.

This class provides also static method to have several appropriate Comparator or SortedSet where the first conventionnal day of the week has been set.

Author:
Arnaud Roques

Field Summary
static DayOfWeek FRIDAY
           
static DayOfWeek MONDAY
           
static DayOfWeek SATURDAY
           
static DayOfWeek SUNDAY
           
static DayOfWeek THURSDAY
           
static DayOfWeek TUESDAY
           
static DayOfWeek WEDNESDAY
           
 
Method Summary
static DayOfWeek fromGcValue(int gc)
          Returns the DayOfWeek object with the specified java.util.Calendar integer constant.
 int getGcValue()
          Return the java.util.Calendar integer constant corresponding to this DayWeek object.
static java.util.Comparator<DayOfWeek> specialComparator(DayOfWeek firstWeekDay)
          Return a Comparator for sorting DayOfWeek.
static java.util.SortedSet<DayOfWeek> specialSet(DayOfWeek firstWeekDay)
          Return a immutable SortedSet with all seven DayOfWeek.
 java.lang.String toString()
          Return a String describing the DayOfWeek
static DayOfWeek valueOf(java.lang.String name)
          Returns the DayOfWeek object with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUNDAY

public static final DayOfWeek SUNDAY

MONDAY

public static final DayOfWeek MONDAY

TUESDAY

public static final DayOfWeek TUESDAY

WEDNESDAY

public static final DayOfWeek WEDNESDAY

THURSDAY

public static final DayOfWeek THURSDAY

FRIDAY

public static final DayOfWeek FRIDAY

SATURDAY

public static final DayOfWeek SATURDAY
Method Detail

specialComparator

public static java.util.Comparator<DayOfWeek> specialComparator(DayOfWeek firstWeekDay)
Return a Comparator for sorting DayOfWeek.

The conventionnal first week of the day must be provided, so that the Comparator can do his job.

Parameters:
firstWeekDay - conventionnal first day of week
Returns:
a Comparator that compare DayOfWeek objects using a precise first day of week

specialSet

public static java.util.SortedSet<DayOfWeek> specialSet(DayOfWeek firstWeekDay)
Return a immutable SortedSet with all seven DayOfWeek.

The conventionnal first week of the day must be provided.

Parameters:
firstWeekDay - conventionnal first day of week
Returns:
a SortedSet with all seven DayOfWeek, starting with firstWeekDay

getGcValue

public int getGcValue()
Return the java.util.Calendar integer constant corresponding to this DayWeek object.

This method should be use only for compatibility with java.util.Calendar.

Returns:
the java.util.Calendar integer constant corresponding to this DayWeek object.

toString

public java.lang.String toString()
Return a String describing the DayOfWeek

Overrides:
toString in class java.lang.Object
Returns:
a String describing the DayOfWeek

valueOf

public static DayOfWeek valueOf(java.lang.String name)
Returns the DayOfWeek object with the specified name.

Parameters:
name - the name of the weekday to be returned
Returns:
the DayOfWeek object with the specified name.
Throws:
java.lang.IllegalArgumentException - if name is not a valid weekday name.

fromGcValue

public static DayOfWeek fromGcValue(int gc)
Returns the DayOfWeek object with the specified java.util.Calendar integer constant.

Parameters:
gc - a integer from java.util.Calendar weekday constants.
Returns:
the DayOfWeek object with the specified java.util.Calendar integer constant.
Throws:
java.lang.IllegalArgumentException - if gc is not a valid integer constant.