com.ds.fw.types.data
Class FwDate

java.lang.Object
  |
  +--com.ds.fw.types.FwSimpleObject
        |
        +--com.ds.fw.types.data.FwDate
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, FwCopyableIF, FwDateConstantsIF, FwDateIF, FwDisplayableIF, FwSimpleObjectIF, java.io.Serializable

public class FwDate
extends FwSimpleObject
implements FwDateIF

See Also:
Serialized Form

Field Summary
 int _day
           
 int _month
           
 int _year
           
 
Fields inherited from interface com.ds.fw.types.data.FwDateConstantsIF
DOW_FRIDAY, DOW_MONDAY, DOW_SATURDAY, DOW_SUNDAY, DOW_THURSDAY, DOW_TUESDAY, DOW_WEDNESDAY, FIRST_DAY_OF_WEEK, FIRST_YEAR, GMT_TIME_ZONE_ID, LAST_YEAR
 
Constructor Summary
FwDate()
          Create a new Date with the default date of Jan 1st, FIRST YEAR.
 
Method Summary
 int _getDate()
          According to the source code this method always return 0 !!!
 void _setDate(int i)
          A very useful method that do NOTHING (may be reserved for future use :))
 void addDay()
          Add a single day
 void addDays(int n)
          Add a number of days to the date
 void addYears(int i)
          Add a number of years
 void beLastDayOfMonth()
          Sets the date to the last date of the month
 void beToday()
          Sets the date to the current date (day, month and year)
 int compareTo(java.lang.Object o)
          Compare two dates
static com.ds.fw.types.data.FwDateIF createDate(java.util.Date d)
          Create a date based on a java.util.Date.
static com.ds.fw.types.data.FwDateIF createDate(int i)
          Create a new date offset from today.
static com.ds.fw.types.data.FwDateIF createDate(int m, int d, int y)
          Create a new date from month, day, and year values.
static com.ds.fw.types.data.FwDateIF createDate(java.lang.String s)
          Set the date by parsing a string in the format mm/dd/ccyy.
static com.ds.fw.types.data.FwDateIF createToday()
          Create a date with today's date.
static com.ds.fw.types.data.FwDateIF createTomorrow()
          Create a date with tomorrow's date.
static com.ds.fw.types.data.FwDateIF createYesterday()
          Create a date with yesterday's date.
 boolean equals(java.lang.Object o)
          Used to verify if two days are equals
 boolean fromString(java.lang.String s)
          Set the date by parsing a string in the format mm/dd/ccyy.
 com.ds.fw.types.data.FwDateIF getDateCopy()
           
 int getDay()
          Gets the day
 int getDayOfWeek()
          Gets the day of week (from 0 to 6)
 java.lang.String getDayOfWeekDisplayString()
          Used to get the string which is displayed for a day of the week
static java.lang.String getDayOfWeekDisplayString(int dow)
          Used to get the string which is displayed for a day of the week
 int getDaysInMonth()
          Gets the days in month , of the month , which is currently set
static int getDaysInMonth(int m, int y)
          Used to find the number of the days in a month
 java.util.Date getJavaDate()
          Gets the date as java.util.Date instance
 int getMonth()
          Gets the month
 com.ds.fw.types.data.FwDateIF getNextDate()
          Gets the next date
 com.ds.fw.types.data.FwDateIF getPreviousDate()
          Gets the previous date
static com.ds.fw.types.data.FwDateIF getToday()
          Create a date with today's date.
static com.ds.fw.types.data.FwDateIF getTomorrow()
          Create a new date with tomorrow's date.
 int getYear()
          Gets the year
 int hashCode()
          Generate a hash code for the date
 boolean isAfter(com.ds.fw.types.data.FwDateIF d)
          Verify if the date, given as argument is after
 boolean isBefore(com.ds.fw.types.data.FwDateIF d)
          Verify if the date given as argument is before
 boolean isLastDayOfMonth()
          Verify if this is the last date of month
 boolean isLeapYear()
          Verify if the year is leap
static boolean isLeapYear(int y)
          Verify if the year given as parameter is a leap year
 boolean isOnOrAfter(com.ds.fw.types.data.FwDateIF d)
          Verify if the date, given as argument is after or it is the same
 boolean isOnOrBefore(com.ds.fw.types.data.FwDateIF d)
          Verify if the date given as argument is before or the same
 boolean isValid()
          Verify if the date is valid
static boolean isValidMonthDayYear(int m, int d, int y)
          Check if a date is valid
 com.ds.fw.types.data.FwDateIF max(com.ds.fw.types.data.FwDateIF d)
          Find the greater of two dates
 com.ds.fw.types.data.FwDateIF min(com.ds.fw.types.data.FwDateIF d)
          Find the less of two dates
static java.util.Calendar newCalendar()
           
static java.util.Calendar newCalendar(int y, int m, int d)
           
 void set(int m, int d, int y)
          Sets the day, month and the year with new values
 void setDate(com.ds.fw.types.data.FwDateIF d)
          Sets the date - date, month and year
 void setDay(int o)
          Sets the day
 void setJavaDate(java.util.Date d)
          Sets the date
 void setMonth(int o)
          Sets the month
 void setYear(int o)
          Sets the year
 void subtractDay()
          Substract a single day
 java.lang.String toStringValue()
          Transform the date as String
 
Methods inherited from class com.ds.fw.types.FwSimpleObject
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, postCopy, printStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ds.fw.types.FwSimpleObjectIF
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, postCopy, toString
 

Field Detail

_day

public int _day

_month

public int _month

_year

public int _year
Constructor Detail

FwDate

public FwDate()
Create a new Date with the default date of Jan 1st, FIRST YEAR.

Method Detail

getToday

public static com.ds.fw.types.data.FwDateIF getToday()
Create a date with today's date.

See Also:
createDate(int)

getTomorrow

public static com.ds.fw.types.data.FwDateIF getTomorrow()
Create a new date with tomorrow's date.

See Also:
createDate(int)

createToday

public static com.ds.fw.types.data.FwDateIF createToday()
Create a date with today's date.

See Also:
createDate(int)

createTomorrow

public static com.ds.fw.types.data.FwDateIF createTomorrow()
Create a date with tomorrow's date.

See Also:
createDate(int)

createYesterday

public static com.ds.fw.types.data.FwDateIF createYesterday()
Create a date with yesterday's date.

See Also:
createDate(int)

createDate

public static com.ds.fw.types.data.FwDateIF createDate(int i)
Create a new date offset from today. 0=today, 1=tomorrow, -1=yesterday, etc...


createDate

public static com.ds.fw.types.data.FwDateIF createDate(java.util.Date d)
Create a date based on a java.util.Date.


createDate

public static com.ds.fw.types.data.FwDateIF createDate(java.lang.String s)
Set the date by parsing a string in the format mm/dd/ccyy. The month and day may each be one or two digits. The year must four digits.


createDate

public static com.ds.fw.types.data.FwDateIF createDate(int m,
                                                       int d,
                                                       int y)
Create a new date from month, day, and year values. No checking is performed; it is assumed that the values form a valid date combination.


getDayOfWeekDisplayString

public static java.lang.String getDayOfWeekDisplayString(int dow)
Used to get the string which is displayed for a day of the week

Parameters:
dow - - a number of a day of the week
Returns:
the string which correspond of a week day
See Also:
FwDateConstantsIF

getDaysInMonth

public static int getDaysInMonth(int m,
                                 int y)
Used to find the number of the days in a month

Parameters:
m - - the month
y - - the year
Returns:
the number of the days in the month

isLeapYear

public static boolean isLeapYear(int y)
Verify if the year given as parameter is a leap year

Parameters:
y - - the year
Returns:
true if it is a leap year , false - otherwise

isValidMonthDayYear

public static boolean isValidMonthDayYear(int m,
                                          int d,
                                          int y)
Check if a date is valid

Parameters:
m - - month
d - - day
y - - year
Returns:
true if it is a valid date , false - otherwise

getDay

public int getDay()
Gets the day

Specified by:
getDay in interface FwDateIF
Returns:
the day

setDay

public void setDay(int o)
Sets the day

Specified by:
setDay in interface FwDateIF
Parameters:
o - - the new day

getMonth

public int getMonth()
Gets the month

Specified by:
getMonth in interface FwDateIF
Returns:
the month

setMonth

public void setMonth(int o)
Sets the month

Specified by:
setMonth in interface FwDateIF
Parameters:
o - - the new month

getYear

public int getYear()
Gets the year

Specified by:
getYear in interface FwDateIF
Returns:
the year

setYear

public void setYear(int o)
Sets the year

Specified by:
setYear in interface FwDateIF
Parameters:
o - - the new year

setDate

public void setDate(com.ds.fw.types.data.FwDateIF d)
Sets the date - date, month and year

Specified by:
setDate in interface FwDateIF
Parameters:
d -

beToday

public void beToday()
Sets the date to the current date (day, month and year)

Specified by:
beToday in interface FwDateIF

beLastDayOfMonth

public void beLastDayOfMonth()
Sets the date to the last date of the month

Specified by:
beLastDayOfMonth in interface FwDateIF

set

public void set(int m,
                int d,
                int y)
Sets the day, month and the year with new values

Specified by:
set in interface FwDateIF
Parameters:
m - - the new day
d - - the new month
y - - the new year

getJavaDate

public java.util.Date getJavaDate()
Gets the date as java.util.Date instance

Specified by:
getJavaDate in interface FwDateIF
Returns:
java.util.Date instance

setJavaDate

public void setJavaDate(java.util.Date d)
Sets the date

Specified by:
setJavaDate in interface FwDateIF
Parameters:
d - - a java.util.Date instance

getDayOfWeek

public int getDayOfWeek()
Gets the day of week (from 0 to 6)

Specified by:
getDayOfWeek in interface FwDateIF
Returns:
the day of the week
See Also:
FwDateConstantsIF

getDaysInMonth

public int getDaysInMonth()
Gets the days in month , of the month , which is currently set

Returns:
the days of the month

addDays

public void addDays(int n)
Add a number of days to the date

Specified by:
addDays in interface FwDateIF
Parameters:
n - - the number of the days , which we add(if n is positive) or substract(if is negative)

addDay

public void addDay()
Add a single day

Specified by:
addDay in interface FwDateIF

subtractDay

public void subtractDay()
Substract a single day

Specified by:
subtractDay in interface FwDateIF

addYears

public void addYears(int i)
Add a number of years

Specified by:
addYears in interface FwDateIF
Parameters:
i - - the number of the years we want to add

getNextDate

public com.ds.fw.types.data.FwDateIF getNextDate()
Gets the next date

Specified by:
getNextDate in interface FwDateIF
Returns:
the next date

getPreviousDate

public com.ds.fw.types.data.FwDateIF getPreviousDate()
Gets the previous date

Specified by:
getPreviousDate in interface FwDateIF
Returns:
the previous date

getDateCopy

public com.ds.fw.types.data.FwDateIF getDateCopy()
Specified by:
getDateCopy in interface FwDateIF

compareTo

public int compareTo(java.lang.Object o)
Compare two dates

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - - the date to compare
Returns:
0 if there are equals, -1 - if the date, given as parameter is before, 1 - if the date, given as parameter is after

equals

public boolean equals(java.lang.Object o)
Used to verify if two days are equals

Overrides:
equals in class java.lang.Object
Parameters:
o -
Returns:
true - if they are equals , false - otherwise

hashCode

public int hashCode()
Generate a hash code for the date

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code for this date

isBefore

public boolean isBefore(com.ds.fw.types.data.FwDateIF d)
Verify if the date given as argument is before

Specified by:
isBefore in interface FwDateIF
Parameters:
d - - the date which we compare
Returns:
- true if it is before , false otherwise (after or equal)

isOnOrBefore

public boolean isOnOrBefore(com.ds.fw.types.data.FwDateIF d)
Verify if the date given as argument is before or the same

Specified by:
isOnOrBefore in interface FwDateIF
Parameters:
d - - the date which we compare
Returns:
- true if it is before or it is the same date, false otherwise (after)

isAfter

public boolean isAfter(com.ds.fw.types.data.FwDateIF d)
Verify if the date, given as argument is after

Specified by:
isAfter in interface FwDateIF
Parameters:
d - - the date which we compare
Returns:
true if it is after, false if it is before or it is the same date

isOnOrAfter

public boolean isOnOrAfter(com.ds.fw.types.data.FwDateIF d)
Verify if the date, given as argument is after or it is the same

Specified by:
isOnOrAfter in interface FwDateIF
Parameters:
d - - the date which we compare
Returns:
true if it is after or it is the same, false if it is before

max

public com.ds.fw.types.data.FwDateIF max(com.ds.fw.types.data.FwDateIF d)
Find the greater of two dates

Specified by:
max in interface FwDateIF
Parameters:
d - - the date which we compare
Returns:
the greater of the two dates

min

public com.ds.fw.types.data.FwDateIF min(com.ds.fw.types.data.FwDateIF d)
Find the less of two dates

Specified by:
min in interface FwDateIF
Parameters:
d - - the date which we compare
Returns:
the less of the two dates

toStringValue

public java.lang.String toStringValue()
Transform the date as String

Specified by:
toStringValue in interface FwSimpleObjectIF
Overrides:
toStringValue in class FwSimpleObject
Returns:
the date as string in mm/dd/yy format

getDayOfWeekDisplayString

public java.lang.String getDayOfWeekDisplayString()
Used to get the string which is displayed for a day of the week

Specified by:
getDayOfWeekDisplayString in interface FwDateIF
Returns:
the string which correspond of a week day

fromString

public boolean fromString(java.lang.String s)
Set the date by parsing a string in the format mm/dd/ccyy. The month and day may each be one or two digits. The year must four digits.

Specified by:
fromString in interface FwDateIF

isValid

public boolean isValid()
Verify if the date is valid

Specified by:
isValid in interface FwDateIF
Returns:
true if it is a valid date , false - otherwise

isLeapYear

public boolean isLeapYear()
Verify if the year is leap

Specified by:
isLeapYear in interface FwDateIF
Returns:
true if it is a leap year , false - otherwise

isLastDayOfMonth

public boolean isLastDayOfMonth()
Verify if this is the last date of month

Returns:
true if it is the last date of the month , false - otherwise

newCalendar

public static java.util.Calendar newCalendar()

newCalendar

public static java.util.Calendar newCalendar(int y,
                                             int m,
                                             int d)

_getDate

public int _getDate()
According to the source code this method always return 0 !!!

Specified by:
_getDate in interface FwDateIF
Returns:
0 - always

_setDate

public void _setDate(int i)
A very useful method that do NOTHING (may be reserved for future use :))

Specified by:
_setDate in interface FwDateIF
Parameters:
i -