public final class TimeOfDay extends LongValue
Values can be constructed using various factory methods:
valueOf(long)
where long
is milliseconds since midnight
valueOf(String)
where the String
is in 'h.mma' format
valueOf(Calendar, String)
where the String
is in 'h.mma' format
valueOf(Duration)
where Duration
is time since midnight
valueOf(Time)
where Time
is some point in time today
valueOf(Calendar, Time)
where Time
is some point in time today
militaryTime(int hour, int minute, int second)
for 24-hour time
time(int hour, int minute, Meridian)
where Meridian
is AM or PM
time(int hour, int minute, int second, Meridian)
where Meridian
is
AM or PM
now()
to construct the current time of day
now(Calendar)
to construct the current time of day using a given
Calendar
If an attempt is made to construct an illegal time of day value (one that is greater than 24
hours worth of milliseconds), an IllegalArgumentException
will be thrown.
Military hours, minutes and seconds of the time of day can be retrieved by calling the
hour
, minute
, and second
methods.
The next occurrence of a given TimeOfDay
can be retrieved by calling
next()
or next(Calendar)
.
Modifier and Type | Class and Description |
---|---|
static class |
TimeOfDay.Meridian
Typesafe AM/PM enumeration.
|
Modifier and Type | Field and Description |
---|---|
static TimeOfDay.Meridian |
AM
Constant for AM time.
|
static TimeOfDay |
MIDNIGHT
Constant for midnight.
|
static TimeOfDay |
NOON
Constant for noon.
|
static TimeOfDay.Meridian |
PM
Constant for PM time.
|
Modifier and Type | Method and Description |
---|---|
boolean |
after(org.apache.wicket.util.time.AbstractTimeValue that)
Returns
true if this Time value is after the given
Time argument's value. |
boolean |
before(org.apache.wicket.util.time.AbstractTimeValue that)
Returns
true if this Time value is before the given
Time argument's value. |
long |
getMilliseconds()
Retrieves the number of milliseconds in this
Time value. |
int |
hour()
Retrieves the hour of the day.
|
static TimeOfDay |
militaryTime(int hour,
int minute,
int second)
Retrieves a
TimeOfDay value on a 24-hour clock. |
int |
minute()
Retrieves the minute.
|
Time |
next()
Retrieves the next occurrence of this
TimeOfDay in local time. |
Time |
next(Calendar calendar)
Retrieves the next occurrence of this
TimeOfDay on the given
Calendar . |
static TimeOfDay |
now()
Retrieves the
TimeOfDay representing 'now'. |
static TimeOfDay |
now(Calendar calendar)
Retrieves the
TimeOfDay representing 'now' on the given Calendar . |
int |
second()
Retrieves the second.
|
static TimeOfDay |
time(int hour,
int minute,
int second,
TimeOfDay.Meridian meridian)
Retrieves a
TimeOfDay on a 12-hour clock. |
static TimeOfDay |
time(int hour,
int minute,
TimeOfDay.Meridian meridian)
Retrieves a
TimeOfDay on a 12-hour clock. |
String |
toString()
Converts this
Time to a String suitable for use in a file system
name. |
String |
toTimeString()
Converts this
Time to a time String using the formatter 'h.mma'. |
String |
toTimeString(Calendar calendar)
Converts this
Time to a Date String using the Date
formatter 'h.mma'. |
static TimeOfDay |
valueOf(Calendar calendar,
String time)
Converts a time
String and Calendar to a TimeOfDay
instance. |
static TimeOfDay |
valueOf(Calendar calendar,
Time time)
Converts a
Time instance and Calendar to a TimeOfDay
instance. |
static TimeOfDay |
valueOf(Duration duration)
Converts a
Duration instance to a TimeOfDay instance. |
static TimeOfDay |
valueOf(long time)
Converts a
long value to a TimeOfDay instance. |
static TimeOfDay |
valueOf(String time)
Converts a
String value to a TimeOfDay instance. |
static TimeOfDay |
valueOf(Time time)
Converts a
String value to a TimeOfDay instance. |
compareTo, equals, greaterThan, greaterThan, greaterThanOrEqual, greaterThanOrEqual, hashCode, lessThan, lessThan, lessThanOrEqual, lessThanOrEqual, max, maxNullSafe, min
public static final TimeOfDay.Meridian AM
public static final TimeOfDay MIDNIGHT
public static final TimeOfDay.Meridian PM
public static final TimeOfDay NOON
public static TimeOfDay militaryTime(int hour, int minute, int second)
TimeOfDay
value on a 24-hour clock.hour
- the hour (0-23)minute
- the minute (0-59)second
- the second (0-59)public static TimeOfDay now()
TimeOfDay
representing 'now'.public static TimeOfDay now(Calendar calendar)
TimeOfDay
representing 'now' on the given Calendar
.calendar
- the Calendar
to useCalendar
public static TimeOfDay time(int hour, int minute, int second, TimeOfDay.Meridian meridian)
TimeOfDay
on a 12-hour clock.hour
- the hour (1-12)minute
- the minute (0-59)second
- the second (0-59)meridian
- AM or PMTimeOfDay
valuepublic static TimeOfDay time(int hour, int minute, TimeOfDay.Meridian meridian)
TimeOfDay
on a 12-hour clock.hour
- the hour (1-12)minute
- the minute (0-59)meridian
- AM of PMTimeOfDay
valuepublic static TimeOfDay valueOf(Calendar calendar, String time) throws ParseException
String
and Calendar
to a TimeOfDay
instance.calendar
- the Calendar
to use when parsing time String
time
- a String
in 'h.mma' formatTimeOfDay
on the given Calendar
ParseException
public static TimeOfDay valueOf(Calendar calendar, Time time)
Time
instance and Calendar
to a TimeOfDay
instance.calendar
- the Calendar
to usetime
- a Time
instanceTimeOfDay
on the given Calendar
public static TimeOfDay valueOf(Duration duration)
Duration
instance to a TimeOfDay
instance.duration
- the Duration
to useTimeOfDay
of the given Duration
public static TimeOfDay valueOf(long time)
long
value to a TimeOfDay
instance.time
- the time in milliseconds todayTimeOfDay
public static TimeOfDay valueOf(String time) throws ParseException
String
value to a TimeOfDay
instance.time
- a String
in 'h.mma' formatTimeOfDay
ParseException
public static TimeOfDay valueOf(Time time)
String
value to a TimeOfDay
instance.time
- a Time
to convert to TimeOfDay
TimeOfDay
in the current time zonepublic int hour()
TimeOfDay
public int minute()
TimeOfDay
public Time next()
TimeOfDay
in local time.TimeOfDay
in local timepublic Time next(Calendar calendar)
TimeOfDay
on the given
Calendar
.calendar
- the Calendar
to useTimeOfDay
on the given Calendar
public int second()
public String toString()
Time
to a String
suitable for use in a file system
name.Time
as a formatted String
Object.toString()
public final boolean after(org.apache.wicket.util.time.AbstractTimeValue that)
true
if this Time
value is after the given
Time
argument's value.that
- the AbstractTimeValue
to compare withtrue
if this Time
value is after that
Time
valuepublic final boolean before(org.apache.wicket.util.time.AbstractTimeValue that)
true
if this Time
value is before the given
Time
argument's value.that
- the AbstractTimeValue
to compare withtrue
if this Time
value is before that
Time
valuepublic final String toTimeString()
Time
to a time String
using the formatter 'h.mma'.Time
String
public final String toTimeString(Calendar calendar)
Time
to a Date String
using the Date
formatter 'h.mma'.calendar
- the Calendar
to use in the conversionDate
String
public final long getMilliseconds()
Time
value.Time
valueCopyright © 2006–2022 Apache Software Foundation. All rights reserved.