public class Hour extends RegularTimePeriod implements java.io.Serializable
RegularTimePeriod
subclasses.Modifier and Type | Field and Description |
---|---|
static int |
FIRST_HOUR_IN_DAY
Useful constant for the first hour in the day.
|
static int |
LAST_HOUR_IN_DAY
Useful constant for the last hour in the day.
|
DEFAULT_TIME_ZONE, WORKING_CALENDAR
Constructor and Description |
---|
Hour()
Constructs a new Hour, based on the system date/time.
|
Hour(java.util.Date time)
Constructs a new instance, based on the supplied date/time and
the default time zone.
|
Hour(java.util.Date time,
java.util.TimeZone zone)
Deprecated.
As of 1.0.13, use the constructor that specifies the locale
also.
|
Hour(java.util.Date time,
java.util.TimeZone zone,
java.util.Locale locale)
Constructs a new instance, based on the supplied date/time evaluated
in the specified time zone.
|
Hour(int hour,
Day day)
Constructs a new Hour.
|
Hour(int hour,
int day,
int month,
int year)
Creates a new hour.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o1)
Returns an integer indicating the order of this Hour object relative to
the specified object:
negative == before, zero == same, positive == after.
|
boolean |
equals(java.lang.Object obj)
Tests the equality of this object against an arbitrary Object.
|
Day |
getDay()
Returns the day in which this hour falls.
|
int |
getDayOfMonth()
Returns the day-of-the-month in which this hour falls.
|
long |
getFirstMillisecond()
Returns the first millisecond of the hour.
|
long |
getFirstMillisecond(java.util.Calendar calendar)
Returns the first millisecond of the hour.
|
int |
getHour()
Returns the hour.
|
long |
getLastMillisecond()
Returns the last millisecond of the hour.
|
long |
getLastMillisecond(java.util.Calendar calendar)
Returns the last millisecond of the hour.
|
int |
getMonth()
Returns the month in which this hour falls.
|
long |
getSerialIndex()
Returns a serial index number for the hour.
|
int |
getYear()
Returns the year in which this hour falls.
|
int |
hashCode()
Returns a hash code for this object instance.
|
RegularTimePeriod |
next()
Returns the hour following this one.
|
static Hour |
parseHour(java.lang.String s)
Creates an Hour instance by parsing a string.
|
void |
peg(java.util.Calendar calendar)
Recalculates the start date/time and end date/time for this time period
relative to the supplied calendar (which incorporates a time zone).
|
RegularTimePeriod |
previous()
Returns the hour preceding this one.
|
java.lang.String |
toString()
Returns a string representation of this instance, for debugging
purposes.
|
createInstance, downsize, getEnd, getFirstMillisecond, getLastMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMiddleMillisecond, getMillisecond, getStart
public static final int FIRST_HOUR_IN_DAY
public static final int LAST_HOUR_IN_DAY
public Hour()
public Hour(int hour, Day day)
hour
- the hour (in the range 0 to 23).day
- the day (null
not permitted).public Hour(int hour, int day, int month, int year)
hour
- the hour (0-23).day
- the day (1-31).month
- the month (1-12).year
- the year (1900-9999).public Hour(java.util.Date time)
time
- the date-time (null
not permitted).Hour(Date, TimeZone)
public Hour(java.util.Date time, java.util.TimeZone zone)
time
- the date-time (null
not permitted).zone
- the time zone (null
not permitted).public Hour(java.util.Date time, java.util.TimeZone zone, java.util.Locale locale)
time
- the date-time (null
not permitted).zone
- the time zone (null
not permitted).locale
- the locale (null
not permitted).public int getHour()
public int getYear()
public int getMonth()
public int getDayOfMonth()
public long getFirstMillisecond()
peg(Calendar)
method.getFirstMillisecond
in class RegularTimePeriod
getLastMillisecond()
public long getLastMillisecond()
peg(Calendar)
method.getLastMillisecond
in class RegularTimePeriod
getFirstMillisecond()
public void peg(java.util.Calendar calendar)
peg
in class RegularTimePeriod
calendar
- the calendar (null
not permitted).public RegularTimePeriod previous()
previous
in class RegularTimePeriod
public RegularTimePeriod next()
next
in class RegularTimePeriod
public long getSerialIndex()
getSerialIndex
in class RegularTimePeriod
public long getFirstMillisecond(java.util.Calendar calendar)
getFirstMillisecond
in class RegularTimePeriod
calendar
- the calendar/timezone (null
not permitted).java.lang.NullPointerException
- if calendar
is
null
.RegularTimePeriod.getLastMillisecond(Calendar)
public long getLastMillisecond(java.util.Calendar calendar)
getLastMillisecond
in class RegularTimePeriod
calendar
- the calendar/timezone (null
not permitted).java.lang.NullPointerException
- if calendar
is
null
.RegularTimePeriod.getFirstMillisecond(Calendar)
public boolean equals(java.lang.Object obj)
This method will return true ONLY if the object is an Hour object representing the same hour as this instance.
equals
in class java.lang.Object
obj
- the object to compare (null
permitted).true
if the hour and day value of the object
is the same as this.public java.lang.String toString()
toString
in class RegularTimePeriod
public int hashCode()
http://developer.java.sun.com/developer/Books/effectivejava
/Chapter3.pdf
hashCode
in class java.lang.Object
public int compareTo(java.lang.Object o1)
compareTo
in interface java.lang.Comparable
o1
- the object to compare.public static Hour parseHour(java.lang.String s)
s
- the hour string to parse.null
if the string is not parseable, the hour
otherwise.