[ Previous section | Next section | This Package | Package List | Table of Contents ]

Class ADate

public class extend.util.ADate extends java.lang.Object {
   public static final int USA
   public static final int European
   public ADate()
   public ADate(int, int, int)
   public int getYear()
   public int getMonth()
   public int getDay()
   public void setYear(int)
   public void setMonth(int)
   public void setDay(int)
   public void nextMonth()
   public void previousMonth()
   public boolean equals(ADate)
   public String toString()
   public String toString(int)
   public int toJulian()
   public int daysInMonth()
   public boolean isLeapYear()
   public String monthName()
   public static String getMonthName(int)
   public int dayOfWeek()
   public String weekdayName()
   public static String getWeekdayName(int)
   public void setSeparator(String)
}
The ADate class provides a non-visual business object to aid in date manipulation.

Fields

USA

public final static int USA
Used to control the format of the date when converted to a string..

European

public final static int European
Used to control the format of the date when converted to a string..

Constructors

ADate

public ADate ()
This is the default constructor for the ADate class. Its date value is set to the current date.

ADate

public ADate (int year, int month, int day)
This is an optional constructor for the ADate class. Its value is set based on the arguments.

Parameters:
year - The year for the date being constructed
month - The month for the date being constructed
day - The day of the month for the date being construncted.

Methods

getYear

public int getYear ()
This method returns the year portion of the date.

Returns:
This method returns an int.

getMonth

public int getMonth ()
This method returns the month portion of the date.

Returns:
This method returns an int.

getDay

public int getDay ()
This method returns the day portion of the date.

Returns:
This method returns an int.

setYear

public void setYear (int year)
This method sets the year portion of the date to the given value.

Parameters:
year - The new year value for the date

setMonth

public void setMonth (int month)
This method sets the month portion of the date to the given value.

Parameters:
month - The new month value for the date

setDay

public void setDay (int day)
This method sets the day portion of the date to the given value.

Parameters:
day - The new day value for the date

nextMonth

public void nextMonth ()
This method sets the date to the first day of the following month.

previousMonth

public void previousMonth ()
This method sets the date to the last day of the previous month.

equals

public boolean equals (ADate date)
This method overrides the inherited Object method and returns true if the given date matches the current date.

Parameters:
date - The date to compare to
Returns:
This method returns boolean.

toString

public String toString ()
This method overrides the inherited Object method and returns the date in YYYY-MM-DD string format. For single digit months and days, leading zeros are guaranteed.

Returns:
This method returns String.

toString

public String toString (int format)
This method overrides the inherited Object method and returns the date in the format indicated by the argument.

Parameters:
format - Identifies the string format to place the date in. It must be USA or European. The examples below show the format each type will produce.
USA July 11, 1996
European 11 July 1996
Returns:
This method returns String.
Throws:
IllegalArgumentException This exception is thrown when any argument is not valid.

toJulian

public int toJulian ()
This method returns the date as an integer in long Julian (YYYYDDD) format.

Returns:
This method returns int.

daysInMonth

public int daysInMonth ()
This method returns the total number of days in the current month.

Returns:
This method returns int.

isLeapYear

public boolean isLeapYear ()
This method returns true if the current year is a leap year, false otherwise.

Returns:
This method returns boolean.

monthName

public String monthName ()
This method returns the text name of the current month.

Returns:
This method returns a String.

getMonthName

public static String getMonthName (int monthNumber)
This method returns the text name of the given month.

Parameters:
monthNumber - The number of the month to get the name for. It must be in the range 1-12.
Returns:
This method returns a String.
Throws:
IllegalArgumentException This exception is thrown when any argument is not valid.

dayOfWeek

public int dayOfWeek ()
This method returns a number indicating the day of week for the current date. 0=Sunday, 1=Monday, ..., 6=Saturday

Returns:
This method returns an int.

weekdayName

public String weekdayName ()
This method returns the text name of the day of week for the current date.

Returns:
This method returns a String.

getWeekdayName

public String getWeekdayName (int dayNumber)
This method returns the text name of the given day.

Parameters:
dayNumber - The number of the day to get the name for. It must be in the range 0-6.
Returns:
This method returns a String.
Throws:
IllegalArgumentException This exception is thrown when any argument is not valid.

setSeparator

public void setSeparatore (String newSeparator)
This method sets the separator string used by the toString() method to format the date. The default separator is the dash character, '-'.

Parameters:
newSeparator - The new string to use as a separator in date formatting. It cannot be null.
Throws:
IllegalArgumentException This exception is thrown when any argument is not valid.

[ Previous section | Next section | This Package | Package List | Table of Contents ]