Package com.globalmentor.iso.datetime
Class ISOTime
- java.lang.Object
-
- com.globalmentor.iso.datetime.ISOTime
-
- All Implemented Interfaces:
ISOTemporal
public class ISOTime extends java.lang.Object implements ISOTemporal
The class representing an ISO time type.- Author:
- Garret Wilson
-
-
Field Summary
Fields Modifier and Type Field Description static ISOTime
MIDNIGHT_UTC
The shared time representing midnight UTC, the time 00:00:00+00:00.
-
Constructor Summary
Constructors Modifier Constructor Description ISOTime(int hours, int minutes, int seconds, int microseconds, ISOUTCOffset utcOffset)
Full Constructor.ISOTime(long time)
Millisecond time constructor.protected
ISOTime(ISOTemporalComponents temporalComponents)
Temporal component constructor.ISOTime(java.util.Date date)
Date constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringBuilder
append(java.lang.StringBuilder stringBuilder)
Appends the canonical lexical representation of this time to a string builder in the form "hh:mm:ss[.s+]+/-hh:mm".int
getHours()
int
getMicroseconds()
int
getMinutes()
int
getSeconds()
ISOUTCOffset
getUTCOffset()
boolean
isMidnight()
java.lang.String
toString()
Returns the canonical lexical representation of this time in the form "hh:mm:ss[.s+]+/-hh:mm".static ISOTime
valueOf(java.lang.String string)
Returns an ISO time object holding the value of the specified string.
-
-
-
Field Detail
-
MIDNIGHT_UTC
public static final ISOTime MIDNIGHT_UTC
The shared time representing midnight UTC, the time 00:00:00+00:00.
-
-
Constructor Detail
-
ISOTime
public ISOTime(int hours, int minutes, int seconds, int microseconds, ISOUTCOffset utcOffset)
Full Constructor.- Parameters:
hours
- The hours, 0-23.minutes
- The minutes, 0-59.seconds
- The seconds, 0-60 (allowing leap-seconds; see ISO 8601:2004(E) 4.2.1).microseconds
- The microseconds, 0-999999.utcOffset
- The UTC offset, ornull
if no UTC offset is known.- Throws:
java.lang.IllegalArgumentException
- if one of the given arguments is outside the allowed range.
-
ISOTime
protected ISOTime(ISOTemporalComponents temporalComponents)
Temporal component constructor.- Parameters:
temporalComponents
- The temporal components from which to construct the class.- Throws:
java.lang.NullPointerException
- if the given temporal components isnull
.
-
ISOTime
public ISOTime(java.util.Date date)
Date constructor. Any date-related information of the given date will be lost; only the time will be kept, in terms of midnight UTC.- Parameters:
date
- The date representing the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.- Throws:
java.lang.NullPointerException
- if the given date isnull
.
-
ISOTime
public ISOTime(long time)
Millisecond time constructor. Any date-related information of the given time will be lost; only the time will be kept, in terms of midnight UTC.- Parameters:
time
- The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
-
-
Method Detail
-
getHours
public final int getHours()
- Returns:
- The hours, 0-23.
-
getMinutes
public final int getMinutes()
- Returns:
- The minutes, 0-59.
-
getSeconds
public final int getSeconds()
- Returns:
- The seconds, 0-60 (allowing leap-seconds; see ISO 8601:2004(E) 4.2.1).
-
getMicroseconds
public final int getMicroseconds()
- Returns:
- The microseconds, 0-999999.
-
getUTCOffset
public ISOUTCOffset getUTCOffset()
- Returns:
- The UTC offset, or
null
if no UTC offset is known.
-
isMidnight
public boolean isMidnight()
- Returns:
true
if this time represents midnight at the beginning of the day (00:00:00:00) in whatever UTC offset, if any, is indicated.
-
valueOf
public static ISOTime valueOf(java.lang.String string) throws ArgumentSyntaxException
Returns an ISO time object holding the value of the specified string.- Parameters:
string
- The string to be parsed as a time.- Returns:
- An ISO time object represented by the string.
- Throws:
java.lang.NullPointerException
- if the given string isnull
ArgumentSyntaxException
- if the given string does not have the correct syntax.
-
append
public java.lang.StringBuilder append(java.lang.StringBuilder stringBuilder)
Appends the canonical lexical representation of this time to a string builder in the form "hh:mm:ss[.s+]+/-hh:mm".- Specified by:
append
in interfaceISOTemporal
- Parameters:
stringBuilder
- The string builder to which the lexical representation will be appended.- Returns:
- The string builder.
-
toString
public java.lang.String toString()
Returns the canonical lexical representation of this time in the form "hh:mm:ss[.s+]+/-hh:mm".- Specified by:
toString
in interfaceISOTemporal
- Overrides:
toString
in classjava.lang.Object
- Returns:
- The canonical lexical representation of this time.
-
-