public class Hour extends RegularTimePeriod implements 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(Date time)
Constructs a new instance, based on the supplied date/time and
the default time zone.
|
Hour(Date time,
TimeZone zone)
Deprecated.
As of 1.0.13, use the constructor that specifies the locale
also.
|
Hour(Date time,
TimeZone zone,
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(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(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(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(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(String s)
Creates an Hour instance by parsing a string.
|
void |
peg(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.
|
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(Date time)
time
- the date-time (null
not permitted).Hour(Date, TimeZone)
public Hour(Date time, TimeZone zone)
time
- the date-time (null
not permitted).zone
- the time zone (null
not permitted).public Hour(Date time, TimeZone zone, 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 Day getDay()
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(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(Calendar calendar)
getFirstMillisecond
in class RegularTimePeriod
calendar
- the calendar/timezone (null
not permitted).NullPointerException
- if calendar
is
null
.RegularTimePeriod.getLastMillisecond(Calendar)
public long getLastMillisecond(Calendar calendar)
getLastMillisecond
in class RegularTimePeriod
calendar
- the calendar/timezone (null
not permitted).NullPointerException
- if calendar
is
null
.RegularTimePeriod.getFirstMillisecond(Calendar)
public boolean equals(Object obj)
This method will return true ONLY if the object is an Hour object representing the same hour as this instance.
public String toString()
toString
in class RegularTimePeriod
public int hashCode()
http://developer.java.sun.com/developer/Books/effectivejava
/Chapter3.pdf
public int compareTo(Object o1)
compareTo
in interface Comparable
o1
- the object to compare.public static Hour parseHour(String s)
s
- the hour string to parse.null
if the string is not parseable, the hour
otherwise.Jas4pp 1.5 © Java Analysis Studio for Particle Physics