|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hackystat.utilities.time.period.Day
public final class Day
Provides a "cousin" of Date that represents only year, month, and day information. Many Hackystat facilities need date information only at the precision of year/month/day. This abstraction represents a single 24 hour time period.
All Day constructors are private or package private. Clients of this class must use the static getInstance() methods to obtain Day instances.
The Calendar is forced to Locale.US to ensure constant week boundaries.
Day instances are immutable.
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
Compares two Day objects. |
static int |
daysBetween(Day day1,
Day day2)
Returns the number of days (positive or negative) between day1 and day2. |
boolean |
equals(java.lang.Object obj)
Two Day instances are equal() iff they have equal year, month, and day fields. |
java.util.Date |
getDate()
Returns a freshly created Date object that corresponds to the current day. |
java.lang.String |
getDayString()
Returns a two character string representing this Day's day (00-31). |
Day |
getFirstDay()
Returns the "first" day in the TimePeriod. |
long |
getFirstTickOfTheDay()
Gets the first tick of the day. |
static Day |
getInstance()
Returns a Day instance corresponding to today. |
static Day |
getInstance(java.util.Date date)
Returns a Day instance corresponding to the passed Date. |
static Day |
getInstance(int year,
int month,
int day)
Returns a Day instance corresponding to the passed year, month, and day. |
static Day |
getInstance(long timestamp)
Returns a Day instance corresponding to the day associated with timestamp. |
static Day |
getInstance(java.lang.String dayString)
Returns a Day instance corresponding to the passed date in dd-MMM-yyyy format. |
static Day |
getInstance(javax.xml.datatype.XMLGregorianCalendar xmlDay)
Returns a Day instance associated with this passed XMLGregorianCalendar. |
long |
getLastTickOfTheDay()
Gets the last tick of the day. |
java.lang.String |
getMediumMonthString()
Returns a three character string representing this Day's month, e.g. |
java.lang.String |
getMonthString()
Returns a two character string representing this Day's month (01-12). |
java.lang.String |
getSimpleDayString()
Gets the simple date string in 2004-03-25 format. |
java.lang.String |
getYearString()
Returns a four character string representing this Day's year (2000, etc.). |
int |
hashCode()
Compute the hashcode following recommendations in "Effective Java". |
Day |
inc(int increment)
Returns a Day instance corresponding to a day plus or minus increment days in the future or past. |
boolean |
isBefore(Day day)
Returns true if this Day preceeds the passed Day, false if the two Days are equal or this day comes after the passed Day. |
java.lang.String |
toString()
Returns this Day instance in YYYY-MM-DD format. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static Day getInstance()
public static Day getInstance(long timestamp)
timestamp
- A UTC time from which a Day instance will be returned.
public static Day getInstance(java.util.Date date)
date
- A date from which a Day instance will be returned.
public static Day getInstance(int year, int month, int day)
year
- Year, such as 2003.month
- Month, such as 0. Note that January is 0!day
- Day, such as 1. The first day is 1.
public static Day getInstance(java.lang.String dayString) throws java.lang.Exception
dayString
- A string in dd-MMM-yyyy US Locale format, such as "01-Jan-2004".
java.lang.Exception
- If problems occur parsing dayString.public static Day getInstance(javax.xml.datatype.XMLGregorianCalendar xmlDay)
xmlDay
- The date.
public Day inc(int increment)
increment
- A positive or negative integer.
public java.util.Date getDate()
public Day getFirstDay()
getFirstDay
in interface TimePeriod
public static int daysBetween(Day day1, Day day2)
day1
- A Day instance.day2
- A Day instance.
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable<java.lang.Object>
o
- A Day instance.
public boolean isBefore(Day day)
day
- The day to be compared.
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- Any object.
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getSimpleDayString()
public java.lang.String getDayString()
public java.lang.String getMonthString()
public java.lang.String getMediumMonthString()
public java.lang.String getYearString()
public long getFirstTickOfTheDay()
public long getLastTickOfTheDay()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |