org.gui4j.util
Class Day

java.lang.Object
  extended byorg.gui4j.util.Day
All Implemented Interfaces:
java.lang.Comparable, Nameable

public final class Day
extends java.lang.Object
implements java.lang.Comparable, Nameable

Represents a day.
Allows to conveniently work with days instead of dates that also include time info.


Method Summary
 int compareDay(Day day)
          Compares this Day to parameter day.
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object obj)
           
 java.util.Date getDate()
           
 int getDayOfWeek()
          Returns the day of the week represented by this Day.
 int getDiff(Day other)
          Returns the number of days between this Day and the specified Day. the result includes both this and the specified Day.
static Day getFirstDayOf(int year, int month)
          Returns the first day of the specified month in the specified year.
 Day getFirstDayOfMonth()
          Returns the first day of the month this Day belongs to.
static Day getFirstDayOfWeek(int year, int week)
          Returns the first day of the specified calendar week in the specified year.
 Day getFirstDayOfYear()
          Returns the first day of the year this Day belongs to.
static Day getInstance(java.util.Date date)
          Public factory method to get an instance of Day from.
 int getJahr()
          Deprecated. use the english named method getYear() instead.
 int getJahrForWeek()
          Deprecated. use the english named method getYearForWeek() instead.
static Day getLastDayOf(int year, int month)
          Returns the last day of the specified month in the specified year.
static Day getLastDayOfYear(int year)
          Returns the last day of the specified year.
 int getMonat()
          Deprecated. replaced by the english named method getMonth().
 int getMonth()
          Returns the month this Day belongs to.
 java.lang.String getNameTag()
           
 java.lang.String getShortTag()
           
static Day getToday()
          Get a Day instance representing today.
 int getWeek()
          Returns the week of year ("calendar week") this Day belongs to.
 int getYear()
          Returns the year this Day belongs to.
 int getYearForWeek()
          Returns the year the week containing this Day belongs to.
 int hashCode()
           
 boolean isWerktag()
          Deprecated. replaced by english named method isWorkday().
 boolean isWorkday()
          Decides if this Day is considered to be a working day.
 Day nextDay()
          Returns the day following this day.
 Day nextDay(int diff)
          Returns the day diff days after this Day.
 Day prevDay()
          Returns the previous Day.
 int sub(Day otherDay)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getDate

public java.util.Date getDate()

isWorkday

public boolean isWorkday()
Decides if this Day is considered to be a working day. Working days are Monday to Friday, i.e. Saturday and Sunday are not working days.

Returns:
true, if this Day represents a working day, false otherwise.

isWerktag

public boolean isWerktag()
Deprecated. replaced by english named method isWorkday().

Returns:
(see isWorkday())

getDayOfWeek

public int getDayOfWeek()
Returns the day of the week represented by this Day.

Returns:
The day of week, represented as one of the constants defined in Calendar, i.e. Calendar.SUNDAY through Calendar.SATURDAY.

getMonth

public int getMonth()
Returns the month this Day belongs to.

Returns:
the month as defined by the Calendar constants Calendar.JANUARY through Calendar.DECEMBER.

getMonat

public int getMonat()
Deprecated. replaced by the english named method getMonth().

Returns:
(see getMonth())

getWeek

public int getWeek()
Returns the week of year ("calendar week") this Day belongs to.
Note: Currently this class implicitly uses the default locale to create its Calendar object so the criteria which define the first week of a year are taken from that default locale.

Returns:
the week of year

getYear

public int getYear()
Returns the year this Day belongs to.

Returns:
the year

getJahr

public int getJahr()
Deprecated. use the english named method getYear() instead.


getYearForWeek

public int getYearForWeek()
Returns the year the week containing this Day belongs to. This is not necessarily the year this Day belongs to: if this Day is part of the first week of a year, the Day itself could still be in the previous year while the week belongs to the next year.

Returns:
the year of this Day's week.

getJahrForWeek

public int getJahrForWeek()
Deprecated. use the english named method getYearForWeek() instead.

Returns:
(see getYearForWeek()).

getInstance

public static Day getInstance(java.util.Date date)
Public factory method to get an instance of Day from.

Parameters:
date - The date for which to create a Day.
Returns:
a Day instance for the given date.

getToday

public static Day getToday()
Get a Day instance representing today.

Returns:
a Day instance representing today.

getFirstDayOf

public static Day getFirstDayOf(int year,
                                int month)
Returns the first day of the specified month in the specified year.

Parameters:
year - year (fully qualified, i.e. four digits required)
month - month according to usage in Calendar (i.e. 0 is first month).
Returns:
Day

getFirstDayOfWeek

public static Day getFirstDayOfWeek(int year,
                                    int week)
Returns the first day of the specified calendar week in the specified year. Note: the returned Day might not be in the specified year if calendar week 1 was specified.

Parameters:
year - year (fully qualified, i.e. four digits required)
week - calendar week
Returns:
the first day of the specified calendar week in the specified year.

getLastDayOf

public static Day getLastDayOf(int year,
                               int month)
Returns the last day of the specified month in the specified year.

Parameters:
year - year (fully qualified, i.e. four digits required)
month - month according to usage in Calendar (i.e. 0 is first month).
Returns:
Day

getLastDayOfYear

public static Day getLastDayOfYear(int year)
Returns the last day of the specified year.

Parameters:
year - year (fully qualified, i.e. four digits required)
Returns:
the last day of the specified year.

nextDay

public Day nextDay()
Returns the day following this day.

Returns:
Day

getDiff

public int getDiff(Day other)
Returns the number of days between this Day and the specified Day. the result includes both this and the specified Day.

Parameters:
other - Day for which to return the number of days between it and this Day. May not be null.
Returns:
int the number of days between this Day and the specified Day.

nextDay

public Day nextDay(int diff)
Returns the day diff days after this Day.
nextDay(1) is equivalent to nextDay(), nextDay(2) returns the day after nextDay() etc.

Parameters:
diff - defines the day to return based on this Day
Returns:
Day

prevDay

public Day prevDay()
Returns the previous Day.

Returns:
Day

getFirstDayOfMonth

public Day getFirstDayOfMonth()
Returns the first day of the month this Day belongs to.

Returns:
the first day of the month this Day belongs to.

getFirstDayOfYear

public Day getFirstDayOfYear()
Returns the first day of the year this Day belongs to.

Returns:
the first day of the year this Day belongs to.

sub

public int sub(Day otherDay)

compareDay

public int compareDay(Day day)
Compares this Day to parameter day.
Returns -1 if this Day is earlier than the specified one. Returns 0 if the Days denote the same day. Returns 1 otherwise.

Parameters:
day - Day to compare this day to.
Returns:
int see above

equals

public boolean equals(java.lang.Object obj)
See Also:
Object.equals(Object)

hashCode

public int hashCode()
See Also:
Object.hashCode()

toString

public java.lang.String toString()
See Also:
Object.toString()

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(Object)

getNameTag

public java.lang.String getNameTag()
Specified by:
getNameTag in interface Nameable
See Also:
Nameable.getNameTag()

getShortTag

public java.lang.String getShortTag()
Specified by:
getShortTag in interface Nameable
See Also:
Nameable.getShortTag()


Copyright © 2002-2005 beck et al. projects GmbH. All Rights Reserved.