org.opengts.util
Class DayNumber

java.lang.Object
  extended by org.opengts.util.DayNumber
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class DayNumber
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable

Performs convenience function on a "Day Number" Number of days since October 15, 1582 (the first day of the Gregorian Calendar)


Field Summary
static java.lang.String DATE_FORMAT_YMD_1
           
static java.lang.String DATE_FORMAT_YMD_2
           
static java.lang.String DEFAULT_DATE_FORMAT
           
 
Constructor Summary
DayNumber(DayNumber other)
          Copy Constructor
DayNumber(int year, int month1, int day)
          Constructor
DayNumber(long dayNumber)
          Constructor
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this DateTime instance
 int compareTo(java.lang.Object other)
          Compares another DayNumber instance to this instance.
 boolean equals(java.lang.Object obj)
          Returns true if the specified DayNumber is equal-to this DayNumber instance
 java.lang.String format(java.lang.String fmt)
          Retuens a formatted Date
 DateTime getDateTime(java.util.TimeZone tmz, int hour24, int minute, int second)
          Returns a DateTime instance with the time set to the beginning of the day
 DateTime getDayEnd(java.util.TimeZone tmz)
          Returns a DateTime instance with the time set to the beginning of the day
 long getDayNumber()
          Gets the Day Number
 int getDayOfMonth()
          Gets the Day of Month (1..31)
 int getDayOfWeek()
          Returns the day of the week
 DateTime getDayStart(java.util.TimeZone tmz)
          Returns a DateTime instance with the time set to the beginning of the day
 int getMonth()
          Gets the Month (1..12)
 int getMonth0()
          Gets the 0-based Month (0..11)
 int getYear()
          Gets the Year
 boolean isLeapYear()
          Returns true if this year represents a leap-year
static DayNumber parseDayNumber(java.lang.String ymdStr)
          Convert specified string to DayNumber.
 java.lang.String toString()
          Returns a String representation of this instance
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATE_FORMAT_YMD_1

public static final java.lang.String DATE_FORMAT_YMD_1
See Also:
Constant Field Values

DATE_FORMAT_YMD_2

public static final java.lang.String DATE_FORMAT_YMD_2
See Also:
Constant Field Values

DEFAULT_DATE_FORMAT

public static final java.lang.String DEFAULT_DATE_FORMAT
See Also:
Constant Field Values
Constructor Detail

DayNumber

public DayNumber(long dayNumber)
Constructor

Parameters:
dayNumber - The number of days since October 15, 1582

DayNumber

public DayNumber(int year,
                 int month1,
                 int day)
Constructor

Parameters:
year - The year (>= 1583)
month1 - The month (1..12)
day - The day of the month

DayNumber

public DayNumber(DayNumber other)
Copy Constructor

Parameters:
other - The other DayNumber from which to copy
Method Detail

parseDayNumber

public static DayNumber parseDayNumber(java.lang.String ymdStr)
Convert specified string to DayNumber. Valid formats are "yyyy/mm/dd" or "yyyy-mm-dd".

Parameters:
ymdStr - The date to parse
Returns:
the parsed DayNumber, or null if the specified format is invalid.

getDayNumber

public long getDayNumber()
Gets the Day Number

Returns:
The day number

getYear

public int getYear()
Gets the Year

Returns:
The Year

getMonth

public int getMonth()
Gets the Month (1..12)

Returns:
The Month

getMonth0

public int getMonth0()
Gets the 0-based Month (0..11)

Returns:
The Month

getDayOfMonth

public int getDayOfMonth()
Gets the Day of Month (1..31)

Returns:
The Day of Month

getDayOfWeek

public int getDayOfWeek()
Returns the day of the week

Returns:
The day of the week (0=Sunday, 6=Saturday)

isLeapYear

public boolean isLeapYear()
Returns true if this year represents a leap-year

Returns:
True if this is a leap-year, false otherwise

getDateTime

public DateTime getDateTime(java.util.TimeZone tmz,
                            int hour24,
                            int minute,
                            int second)
Returns a DateTime instance with the time set to the beginning of the day

Parameters:
tmz - The TimeZone
hour24 - The 24-hour of the day
minute - The minute of the hour
second - The second of the minute
Returns:
The DateTime instance

getDayStart

public DateTime getDayStart(java.util.TimeZone tmz)
Returns a DateTime instance with the time set to the beginning of the day

Parameters:
tmz - The TimeZone
Returns:
The DateTime instance

getDayEnd

public DateTime getDayEnd(java.util.TimeZone tmz)
Returns a DateTime instance with the time set to the beginning of the day

Parameters:
tmz - The TimeZone
Returns:
The DateTime instance

format

public java.lang.String format(java.lang.String fmt)
Retuens a formatted Date

Parameters:
fmt - The Date/Time format
Returns:
The formatted date

toString

public java.lang.String toString()
Returns a String representation of this instance

Overrides:
toString in class java.lang.Object
Returns:
A String representation of this instance

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified DayNumber is equal-to this DayNumber instance

Overrides:
equals in class java.lang.Object
Parameters:
obj - the other DayNumber instance
Returns:
True if the specified DayNumber is equal-to this DayNumber instance

compareTo

public int compareTo(java.lang.Object other)
Compares another DayNumber instance to this instance.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
other - The other DayNumber instance.
Returns:
<0 of the other DayNumber instance is before this instance, 0 if the other DayNumber instance is equal to this instance, and >0 if the other DayNumber instance is after this instance.

clone

public java.lang.Object clone()
Returns a clone of this DateTime instance

Overrides:
clone in class java.lang.Object
Returns:
A clone of this DateTime instance