|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TimeOfDay
Represents a specific time of the day (hours, minutes, seconds, milliseconds) in the range 00:00:00.000 - 23:59:59.000.
These time objects are always immutable - they cannot be changed once created.
The natural order of this class orders times in chronological order, and two instances are considered equal if they represent the same hour, minute, second and millisecond.
Example usage
Create new instances: |
TimeOfDay.factory.now() TimeOfDay.factory.getDefault() TimeOfDay.factory.parse(...)
|
Formatting: |
TimeOfDay.iso().formatXXX() TimeOfDay.eur().formatXXX() TimeOfDay.us().formatXXX()
|
Serializing |
TimeOfDay.serialize() TimeOfDay.factory.deserialize()
|
Field Summary | |
---|---|
static TimeOfDayFactory |
factory
A default implementation of a TimeOfDayFactory , for creating new
instances. |
Method Summary | |
---|---|
boolean |
equals(Object other)
|
TimeOfDayFormatter |
eur()
Provides a formatter for this time instance that formats times of day according to some de-facto European standard. |
int |
hashCode()
|
int |
hour()
|
boolean |
isAfter(int hours,
int minutes)
Determines if this is after (inclusive) the given time of day. |
boolean |
isAfter(int hours,
int minutes,
int seconds)
Determines if this is after (inclusive) the given time of day. |
boolean |
isBefore(int hours,
int minutes)
Determines if this is before (exclusive) the given time of day. |
boolean |
isBefore(int hours,
int minutes,
int seconds)
Determines if this is before (exclusive) the given time of day. |
boolean |
isLaterHourThan(TimeOfDay time)
Determines whether this is in a later hour than the given time of day. |
boolean |
isLaterMinuteThan(TimeOfDay time)
Determines whether this is in a later minute than the given time of day. |
boolean |
isLaterSecondThan(TimeOfDay time)
Determines whether this is in a later second than the given time. |
TimeOfDayFormatter |
iso()
Provides a formatter for this time instance that formats time of day according to the ISO-8601 standard. |
boolean |
isSameHourAs(TimeOfDay time)
Determines whether this is in the same hour as the given time of day. |
boolean |
isSameMinuteAs(TimeOfDay time)
Determines whether this is in the same minute (of the same hour) as the given time of day. |
boolean |
isSameSecondAs(TimeOfDay time)
Determines whether this is in the same second (of the same minute, and hour) as the given time of day. |
int |
millis()
|
int |
minute()
|
TimeOfDay |
plusHours(int offset)
Adds or subtracts the given number of hours to this time of day. |
TimeOfDay |
plusMillis(int offset)
Adds or subtracts the given number of milliseconds to this time of day. |
TimeOfDay |
plusMinutes(int offset)
Adds or subtracts the given number of minutes to this time of day. |
TimeOfDay |
plusSeconds(int offset)
Adds or subtracts the given number of seconds to this time of day. |
int |
second()
|
String |
serialize()
|
int |
toInt()
Creates an int representation of the time of day, which when written in base 10 is the string hhmmssnnn , where nnn is
the milliseconds. |
String |
toString()
Overrides Object.toString() . |
TimeOfDayFormatter |
us()
Provides a formatter for this time instance that formats times of day according to the US standard. |
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Field Detail |
---|
static final TimeOfDayFactory factory
TimeOfDayFactory
, for creating new
instances. The factory will create serializable
instances.
Method Detail |
---|
int hour()
int minute()
int second()
int millis()
TimeOfDay plusHours(int offset)
offset
- The offset in hours. Can be positive, zero or negative.
TimeOutOfRangeException
- If the resulting time is out of range.TimeOfDay plusMinutes(int offset)
offset
- The offset in minutes. Can be positive, zero or negative.
TimeOutOfRangeException
- If the resulting time is out of range.TimeOfDay plusSeconds(int offset)
offset
- The offset in seconds. Can be positive, zero or negative.
TimeOutOfRangeException
- If the resulting time is out of range.TimeOfDay plusMillis(int offset)
offset
- The offset in millis. Can be positive, zero or negative.
TimeOutOfRangeException
- If the resulting time is out of range.boolean isAfter(int hours, int minutes)
hours
- The hour part of the time of day to compare to, in the range
0-23.minutes
- The minute part of the time of day to compare to, in the
range 0-59.
boolean isAfter(int hours, int minutes, int seconds)
hours
- The hour part of the time of day to compare to, in the range
0-23.minutes
- The minute part of the time of day to compare to, in the
range 0-59.seconds
- The second part of the time of day to compare to, in the
range 0-59.
boolean isBefore(int hours, int minutes)
hours
- The hour part of the time of day to compare to, in the range
0-23.minutes
- The minute part of the time of day to compare to, in the
range 0-59.
boolean isBefore(int hours, int minutes, int seconds)
hours
- The hour part of the time of day to compare to, in the range
0-23.minutes
- The minute part of the time of day to compare to, in the
range 0-59.seconds
- The second part of the time of day to compare to, in the
range 0-59.
boolean isLaterHourThan(TimeOfDay time)
time
- The time of day to compare to.
boolean isSameHourAs(TimeOfDay time)
time
- The time of day to compare to.
boolean isLaterMinuteThan(TimeOfDay time)
time
- The time of day to compare to.
boolean isSameMinuteAs(TimeOfDay time)
time
- The time of day to compare to.
boolean isLaterSecondThan(TimeOfDay time)
time
- The time of day to compare to.
boolean isSameSecondAs(TimeOfDay time)
time
- The time of day to compare to.
int hashCode()
hashCode
in class Object
boolean equals(Object other)
equals
in class Object
TimeOfDayFormatter iso()
See also eur()
and us()
. Incidentally, the three
formatting standards ISO, EUR and US coincide for times of day, but they
are still kept separate to follow the pattern of Time
and
DayDate
formatters.
TimeOfDayFormatter eur()
See also iso()
and us()
. Incidentally, the three
formatting standards ISO, EUR and US coincide for times of day, but they
are still kept separate to follow the pattern of Time
and
DayDate
formatters.
TimeOfDayFormatter us()
See also iso()
and eur()
. Incidentally, the three
formatting standards ISO, EUR and US coincide for times of day, but they
are still kept separate to follow the pattern of Time
and
DayDate
formatters.
String serialize()
hhmmssnnn
, where
nnn
is the milliseconds.String toString()
Object.toString()
.
toString
in class Object
hh:mm:ss.nnn
, where
nnn
is the milliseconds.int toInt()
hhmmssnnn
, where nnn
is
the milliseconds. E.g, the time 16:42:14.308 is represented as the
integer 164214308. Note that the maximum value is 235959999, which is a
valid int.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |