waba.util
Class Date

java.lang.Object
  |
  +--waba.util.Date

public class Date
extends java.lang.Object

The Date class is a general date data type(Object) that is similar to those built in to other languages. It supports all days from January 1st, 1983 through December 31st, 2999. It checks to make sure that the dates that are instanciated or changed exist and if they don't it defaults at today. It provides methods to advance the date backwards and forwards by increments of day, week, and month. It provides comparisons =,>,<. Added by Allan C. Solomon and modified by guich.


Field Summary
static int APRIL
           
static int AUGUST
           
static boolean BACKWARD
           
static int DECEMBER
           
static int FEBRUARY
           
static boolean FORWARD
           
static int FRIDAY
           
static int JANUARY
           
static int JULY
           
static int JUNE
           
static int MARCH
           
static int MAY
           
static int MONDAY
           
static int NOVEMBER
           
static int OCTOBER
           
static int SATURDAY
           
static int SEPTEMBER
           
static int SUNDAY
           
static int THRUSDAY
           
static int TUESDAY
           
static int WEDNESDAY
           
 
Constructor Summary
Date()
          Constructs a Date object set to the current date.
Date(int sentDate)
          Constructs a Date object set to the passed int in the YYYYMMDD format
Date(int sentDay, int sentMonth, int sentYear)
          Constructs a Date object set to the passed day, month, and year.
Date(java.lang.String strDate)
          Constructs a Date object set to a passed string in the format specified in the palm preferences.
Date(java.lang.String strDate, byte dateFormat)
          Constructs a Date object set to a passed string in the format specified in the dateFormat parameter (it must be one of the DATE_XXX constants).
 
Method Summary
 void advance(int numberDays)
          Advances the date by a passed integer.
 void advanceMonth()
          Advances the date to the beginning of the next month.
 void advanceMonth(boolean b)
          Advances the date to the beginning of the next or previous month.
 void advanceWeek()
          Advances the date to the beginning of the next week.
 void advanceWeek(boolean b)
          Advances the date to the beginning of the next or previous week.
 boolean equals(Date sentDate)
          Checks to see if the Date object passed occurs at the same time as the existing Date object.
static java.lang.String formatDate(int day, int month, int year)
          formats the date specified with the palm preferences, zero padded.
static java.lang.String formatDate(int day, int month, int year, byte dateFormat)
          formats the date specified with the dateFormat parameter, zero padded.
 java.lang.String formatDayMonth()
          formats the day/month specified with the Settings.dateFormat, zero padded.
 java.lang.String getDate()
          Returns the date in a string format.
 int getDateInt()
          Returns the date in a integer format.
 int getDay()
          Returns the day.
 int getDayOfWeek()
          Returns the day of week
 int getDaysInMonth()
          Returns number of days in the set month.
 int getDaysInMonth(int month)
           
 int getMonth()
          Returns the month.
static java.lang.String getMonthName(int m)
           
 int getWeek()
          Calculates and returns the ordinal value of the week(1-52).
 int getYear()
          Returns the year.
 boolean isAfter(Date sentDate)
          Checks to see if the Date object passed occurs after the existing Date object.
 boolean isBefore(Date sentDate)
          Checks to see if the Date object passed occurs before the existing Date object.
 void setToday()
          sets this date object to be the current day
 java.lang.String toString()
          Returns the date in a string format.
 
Methods inherited from class java.lang.Object
hashCode
 

Field Detail

SUNDAY

public static final int SUNDAY

MONDAY

public static final int MONDAY

TUESDAY

public static final int TUESDAY

WEDNESDAY

public static final int WEDNESDAY

THRUSDAY

public static final int THRUSDAY

FRIDAY

public static final int FRIDAY

SATURDAY

public static final int SATURDAY

JANUARY

public static final int JANUARY

FEBRUARY

public static final int FEBRUARY

MARCH

public static final int MARCH

APRIL

public static final int APRIL

MAY

public static final int MAY

JUNE

public static final int JUNE

JULY

public static final int JULY

AUGUST

public static final int AUGUST

SEPTEMBER

public static final int SEPTEMBER

OCTOBER

public static final int OCTOBER

NOVEMBER

public static final int NOVEMBER

DECEMBER

public static final int DECEMBER

FORWARD

public static final boolean FORWARD

BACKWARD

public static final boolean BACKWARD
Constructor Detail

Date

public Date()
Constructs a Date object set to the current date.

Date

public Date(java.lang.String strDate,
            byte dateFormat)
Constructs a Date object set to a passed string in the format specified in the dateFormat parameter (it must be one of the DATE_XXX constants). The constructor auto-detects the seperator. If an invalid date is passed, sets to the current date;
Parameters:
strDate- - string that should have the format specified in the palm preferences. Note: does not have to be seperated by the '-' character it can be seperated by any non-number.

Date

public Date(java.lang.String strDate)
Constructs a Date object set to a passed string in the format specified in the palm preferences. The constructor auto-detects the seperator. If an invalid date is passed, sets to the current date;
Parameters:
strDate- - string that should have the format specified in the palm preferences. Note: does not have to be seperated by the '-' character it can be seperated by any non-number.

Date

public Date(int sentDate)
Constructs a Date object set to the passed int in the YYYYMMDD format
Parameters:
sentDate - - an integer in the YYYYMMDD format

Date

public Date(int sentDay,
            int sentMonth,
            int sentYear)
Constructs a Date object set to the passed day, month, and year.
Parameters:
sentDay - - an integer that must be between 1 and the last day in the month.
sentMonth - - an integer that must be between 1 and 12.
sentYear - - an integer that must be between 1983 and 2999.
Method Detail

setToday

public void setToday()
sets this date object to be the current day

getDayOfWeek

public int getDayOfWeek()
Returns the day of week
Returns:
integer representation of day of week. Integers refer to static constants of day of week.

getDay

public int getDay()
Returns the day.
Returns:
integer value of day.

getMonth

public int getMonth()
Returns the month.
Returns:
integer value of the month.

getYear

public int getYear()
Returns the year.
Returns:
integer value of the year.

getWeek

public int getWeek()
Calculates and returns the ordinal value of the week(1-52).
Returns:
integer representation of ordinal value of the week within the set year.

formatDayMonth

public java.lang.String formatDayMonth()
formats the day/month specified with the Settings.dateFormat, zero padded.

formatDate

public static java.lang.String formatDate(int day,
                                          int month,
                                          int year,
                                          byte dateFormat)
formats the date specified with the dateFormat parameter, zero padded.

formatDate

public static java.lang.String formatDate(int day,
                                          int month,
                                          int year)
formats the date specified with the palm preferences, zero padded.

getDate

public java.lang.String getDate()
Returns the date in a string format.
Returns:
string representation of the date in the current palm settings

toString

public java.lang.String toString()
Returns the date in a string format.
Overrides:
toString in class java.lang.Object
Returns:
string representation of the date in the current palm settings

getDateInt

public int getDateInt()
Returns the date in a integer format.
Returns:
integer representation of the date (year * 10000) + (month *100) + day

getDaysInMonth

public int getDaysInMonth()
Returns number of days in the set month.
Returns:
integer containing number of days in set month.

getDaysInMonth

public int getDaysInMonth(int month)

getMonthName

public static java.lang.String getMonthName(int m)

isBefore

public boolean isBefore(Date sentDate)
Checks to see if the Date object passed occurs before the existing Date object.
Parameters:
Date - object to compare with existing.
Returns:
boolean stating whether or not it occurs before existing date.

isAfter

public boolean isAfter(Date sentDate)
Checks to see if the Date object passed occurs after the existing Date object.
Parameters:
Date - object to compare with existing.
Returns:
boolean stating whether or not it occurs after existing date.

equals

public boolean equals(Date sentDate)
Checks to see if the Date object passed occurs at the same time as the existing Date object.
Parameters:
Date - object to compare with existing.
Returns:
boolean stating whether or not it occurs at the same time as existing date.

advanceWeek

public void advanceWeek()
Advances the date to the beginning of the next week.

advanceWeek

public void advanceWeek(boolean b)
Advances the date to the beginning of the next or previous week.
Parameters:
b - - static variables FORWARD or BACKWARD instructs the method to either move to the next or previous week

advanceMonth

public void advanceMonth()
Advances the date to the beginning of the next month.

advanceMonth

public void advanceMonth(boolean b)
Advances the date to the beginning of the next or previous month.
Parameters:
b - - static variables FORWARD or BACKWARD instructs the method to either move to the next or previous month

advance

public void advance(int numberDays)
Advances the date by a passed integer.
Parameters:
numberDays - - integer containing number of days that the date should change can be positive or negitive