Class UTCTime
java.lang.Object
net.okapia.osid.primordium.calendaring.time.spi.AbstractTime
net.okapia.osid.primordium.calendaring.time.spi.AbstractConfigurableTime
net.okapia.osid.primordium.calendaring.time.spi.Abstract246060Time
net.okapia.osid.primordium.calendaring.time.UTCTime
- All Implemented Interfaces:
Serializable, Comparable<Time>, OsidPrimitive, Time, Time, OsidPrimitive
An implementation of a Time based on UTC using a
UTCTimeDefinition.
Currently, leap seconds are not supported in this class.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classATimeFactorythat buildsUTCTimeinstances.static classThe TimeSpecifier is used to constructUTCTimes. -
Field Summary
Fields inherited from class AbstractTime
PLANCKS_IN_MICROQUECTOSECONDModifier and TypeFieldDescriptionprotected static final intthe plancks in microquectosecond -
Constructor Summary
ConstructorsConstructorDescriptionUTCTime(long hour, long minute, long second) Constructs a newUTCTimewith second resolution.UTCTime(UTCTime.UTCTimeSpecifier specifier) Constructs a newUTCTime. -
Method Summary
Modifier and TypeMethodDescriptionstatic Timetime(long hour) Creates a time at hour resolution.static Timetime(long hour, long minute) Creates a time at minute resolution.static Timetime(long hour, long minute, long second) Creates a time at second resolution.static Timetime(long hour, long minute, long second, BigDecimal fractionalSecond) Creates a time with a fractional second.static TimeReturns aTimeparsed from a time string.static TimeCreates a time from a JavaLocalTime.static Timeunknown()Gets an unknown date.static TimevalueOf(long hour) Creates a time at hour resolution.static TimevalueOf(long hour, long minute) Creates a time at minute resolution.static TimevalueOf(long hour, long minute, long second) Creates a time at second resolution.static TimevalueOf(long hour, long minute, long second, BigDecimal fractionalSecond) Creates a time with a fractional second.static TimeReturns a Time for a time format.static TimeCreates a time from a JavaLocalTime.Methods inherited from class Abstract246060Time
parseTime, toStringMethods inherited from class AbstractConfigurableTime
compare, compareTo, denormalizeTime, equals, getTimeDefinition, getTimeFactory, hashCode, isExclusive, isGreater, isInclusive, isLess, minus, minus, parseDecimal, plus, plus, shiftModifier and TypeMethodDescriptionprotected intcompare(Time time1, Time time2, TimeDefinition definition) Compares two normalized finite times.intCompares this Time with the specified Time for ordering.final Time[]Returns an interval based on this Time derived by its granularity.final booleanDetermines if the givenTimeis equal to this one.protected TimeDefinitionGets the time definition.protected TimeFactoryGets the time factory.final inthashCode()Returns a hash code value for thisTimebased on the type, granularity and values.final booleanisExclusive(Time time) Tests if the range of this Time, as specified by its granularity does not overlap the given Time.booleanTests if this Time is greater than the given Time.final booleanisInclusive(Time time) Tests if the range of this Time, as specified by its granularity, includes the given Time ranged by its granularity.final booleanTests if this Time is less than the given Time.minus(long amount, DateTimeResolution unit) Subtracts a number of a clock resolution's units from this time of day, wrapping around the day.Subtracts a duration's clock part from this time of day, wrapping around the day.protected static TimeparseDecimal(TimeFactory factory, String str) Parses the decimal portion of the seconds.plus(long amount, DateTimeResolution unit) Adds a number of a clock resolution's units to this time of day, wrapping around the day -- 23:00 plus two hours is 01:00.Adds a duration's clock part (hours, minutes, seconds) to this time of day, wrapping around the day.shift(DateTimeResolution unit, long amount) Shifts this time of day byamountunits ofunit, reporting any whole days that overflow so a date can absorb them.Methods inherited from class AbstractTime
formatDecimal, formatSignificantDigits, getAttoseconds, getDecimalPlaces, getFemtoseconds, getGranularity, getGranularityMultiplier, getHour, getMicroquectoseconds, getMicroseconds, getMilliquectoseconds, getMilliseconds, getMinute, getNanoseconds, getPicoseconds, getPlanckseconds, getQuectoseconds, getRontoseconds, getSecond, getTimeType, getYoctoseconds, getZeptosecondsModifier and TypeMethodDescriptionprotected static StringformatDecimal(Time time) Formats the decimal portion of a Time.protected static StringformatSignificantDigits(long num, int n) Formats significant digits to a number of places.final longGets the number of attoseconds of the femtoseconds 0-999.protected static intgetDecimalPlaces(DateTimeResolution granularity) Gets the number of decimal places implied by a granularity.final longGets the number of femtoseconds of the picosecond 0-999.final DateTimeResolutionGets the granularity of this time.final longIf the granularity of the time equalsgetGranularity(),then the multiplier is 1.final longgetHour()Gets the hour of the day 0-23.final longGets the number of undaseconds of the vatosecond 0-999.final longGets the number of microseconds of the second 0-999.final longGets the number of vatoseconds of the xoxxosecond 0-999.final longGets the number of milliseconds in this second 0-999.final longGets the minute of the hour 0-59.final longGets the number of nanoseconds of the microsecond 0-999.final longGets the number of picoseconds of the nanosecond 0-999.final longGets the number of Plancks of the vatoseconds.final longGets the number of weebleseconds of the xoxxosecond 0-999.final longGets the number of xoxxoseconds of the yoctosecond 0-999.final longGets the second of the minute 0-59.final TypeGets the time type.final longGets the number of yoctoseconds of the picosecond 0-999.final longGets the number of zeptoseconds of the attosecond 0-999.
-
Constructor Details
-
UTCTime
public UTCTime(long hour, long minute, long second) Constructs a newUTCTimewith second resolution.- Parameters:
hour- the hourminute- the minutesecond- the second- Throws:
InvalidArgumentException-hour,minute, orsecondis negative, orhouris greater than 23minuteis greater than 59, orsecondis greater than 60
-
UTCTime
Constructs a newUTCTime.- Parameters:
specifier- a time specifier- Throws:
NullArgumentException-specifierisnull
-
-
Method Details
-
valueOf
Returns a Time for a time format.- Parameters:
s- the s- Returns:
- a string
- Throws:
InvalidArgumentException- cannot parse stringNullArgumentException-sisnull
-
time
Returns aTimeparsed from a time string. An alias forvalueOf(String).- Parameters:
s- the time string- Returns:
- the parsed Time
- Throws:
InvalidArgumentException- cannot parse stringNullArgumentException-sisnull
-
valueOf
Creates a time at hour resolution.- Parameters:
hour- the hour- Returns:
- a Time
- Throws:
InvalidArgumentException-houris out of range
-
valueOf
Creates a time at minute resolution.- Parameters:
hour- the hourminute- the minute- Returns:
- a Time
- Throws:
InvalidArgumentException- a component is out of range
-
valueOf
Creates a time at second resolution.- Parameters:
hour- the hourminute- the minutesecond- the second- Returns:
- a Time
- Throws:
InvalidArgumentException- a component is out of range
-
valueOf
Creates a time from a JavaLocalTime. The resolution follows the value's actual precision: second when it has no fraction, else millisecond, microsecond, or nanosecond by the finest non-zero part.- Parameters:
time- a Java time LocalTime- Returns:
- a Time
- Throws:
NullArgumentException-timeisnull
-
time
Creates a time at hour resolution. Equivalent tovalueOf(long).- Parameters:
hour- the hour- Returns:
- a Time
-
time
Creates a time at minute resolution. Equivalent tovalueOf(long, long).- Parameters:
hour- the hourminute- the minute- Returns:
- a Time
-
time
Creates a time at second resolution. Equivalent tovalueOf(long, long, long).- Parameters:
hour- the hourminute- the minutesecond- the second- Returns:
- a Time
-
time
Creates a time from a JavaLocalTime. Equivalent tovalueOf(java.time.LocalTime).- Parameters:
localTime- a Java time LocalTime- Returns:
- a Time
- Throws:
NullArgumentException-localTimeisnull
-
valueOf
Creates a time with a fractional second. The resolution follows the number of fractional digits: each group of three is a finer unit (millisecond, microsecond, ...) and a partial final group carries a multiplier (one digit means hundreds, two means tens). A fraction finer than a microquectosecond (more than 36 digits) is truncated to planck seconds, the smallest representable unit.- Parameters:
hour- the hourminute- the minutesecond- the secondfractionalSecond- the fraction of a second, in [0, 1)- Returns:
- a Time
- Throws:
InvalidArgumentException-fractionalSecondis not in [0, 1), or a component is out of rangeNullArgumentException-fractionalSecondisnull
-
time
Creates a time with a fractional second. Equivalent tovalueOf(long, long, long, BigDecimal).- Parameters:
hour- the hourminute- the minutesecond- the secondfractionalSecond- the fraction of a second, in [0, 1)- Returns:
- a Time
- Throws:
InvalidArgumentException-fractionalSecondis not in [0, 1), or a component is out of rangeNullArgumentException-fractionalSecondisnull
-
unknown
-