Package org.apache.uima.internal.util
Class TimeSpan
- java.lang.Object
-
- org.apache.uima.internal.util.TimeSpan
-
public class TimeSpan extends java.lang.ObjectEncode a span of time. The main purpose of this class is to provide a printing utility for time spans. E.g., 1081 ms should be printed as 1.081 s, 108101 ms should be printed as 1 min 48.101 s, etc.Note that the largest value you can represent with this class is 9223372036854775807 (
Long.MAX_VALUE), or equivalently, 292471208 yrs 247 days 7 hrs 12 min 55.807 sec. Overflow is not handled gracefully by this class.Also note that for the purposes of this class, a year has 365 days. I.e., a year corresponds to
365 * 24 * 60 * 60 * 1000ms.
-
-
Field Summary
Fields Modifier and Type Field Description private longallprivate intdaysprivate static java.lang.StringdaysStringprivate inthoursprivate static java.lang.StringhoursStringprivate booleanknowsFullprivate booleanknowsMSprivate intmillisecondsprivate intminutesprivate static java.lang.StringminutesStringprivate static longmsDayprivate static longmsHourprivate static longmsMinuteprivate static longmsSecondprivate static java.lang.StringmsStringprivate static longmsYearprivate intsecondsprivate static java.lang.StringsecondsStringprivate static java.lang.StringunknownTimeprivate intyearsprivate static java.lang.StringyearsString
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidensureAll()private voidensureFull()intgetDays()Get the day fraction of this object.longgetFullMilliseconds()Get the length of theTimeSpanas milliseconds.intgetHours()Get the hour fraction of this object.intgetMilliseconds()Get the millisecond fraction of this object.intgetMinutes()Get the minute fraction of this object.intgetSeconds()Get the second fraction of this object.intgetYears()Get the year fraction of this object.booleanisInstantiated()booleansetDays(int days)Set the day fraction of thisTimeSpan.booleansetFullMilliseconds(long milliseconds)Set the fullTimeSpanin terms of milliseconds.booleansetHours(int hours)Set the hour fraction of thisTimeSpan.booleansetMilliseconds(int milliseconds)Set the millisecond fraction of thisTimeSpan.booleansetMinutes(int minutes)Set the minute fraction of thisTimeSpan.booleansetSeconds(int seconds)Set the second fraction of thisTimeSpan.booleansetYears(int years)Set the year fraction of thisTimeSpan.java.lang.StringtoString()
-
-
-
Field Detail
-
all
private long all
-
years
private int years
-
days
private int days
-
hours
private int hours
-
minutes
private int minutes
-
seconds
private int seconds
-
milliseconds
private int milliseconds
-
knowsFull
private boolean knowsFull
-
knowsMS
private boolean knowsMS
-
msSecond
private static final long msSecond
- See Also:
- Constant Field Values
-
msMinute
private static final long msMinute
- See Also:
- Constant Field Values
-
msHour
private static final long msHour
- See Also:
- Constant Field Values
-
msDay
private static final long msDay
- See Also:
- Constant Field Values
-
msYear
private static final long msYear
- See Also:
- Constant Field Values
-
yearsString
private static final java.lang.String yearsString
- See Also:
- Constant Field Values
-
daysString
private static final java.lang.String daysString
- See Also:
- Constant Field Values
-
hoursString
private static final java.lang.String hoursString
- See Also:
- Constant Field Values
-
minutesString
private static final java.lang.String minutesString
- See Also:
- Constant Field Values
-
secondsString
private static final java.lang.String secondsString
- See Also:
- Constant Field Values
-
msString
private static final java.lang.String msString
- See Also:
- Constant Field Values
-
unknownTime
private static final java.lang.String unknownTime
- See Also:
- Constant Field Values
-
-
Method Detail
-
isInstantiated
public boolean isInstantiated()
- Returns:
true, if the object has been instantiated with a legal interval;false, else.
-
setYears
public boolean setYears(int years)
Set the year fraction of thisTimeSpan.- Parameters:
years- The number of years.- Returns:
false, ifyears < 0;true, else.
-
setDays
public boolean setDays(int days)
Set the day fraction of thisTimeSpan.- Parameters:
days- The number of days.- Returns:
false, ifdays < 0;true, else.
-
setHours
public boolean setHours(int hours)
Set the hour fraction of thisTimeSpan.- Parameters:
hours- The number of hours.- Returns:
false, ifhours < 0;true, else.
-
setMinutes
public boolean setMinutes(int minutes)
Set the minute fraction of thisTimeSpan.- Parameters:
minutes- The number of minutes.- Returns:
false, ifminutes < 0;true, else.
-
setSeconds
public boolean setSeconds(int seconds)
Set the second fraction of thisTimeSpan.- Parameters:
seconds- The number of seconds.- Returns:
false, ifseconds < 0;true, else.
-
setMilliseconds
public boolean setMilliseconds(int milliseconds)
Set the millisecond fraction of thisTimeSpan.- Parameters:
milliseconds- The number of milliseconds.- Returns:
false, ifmilliseconds < 0;true, else.
-
setFullMilliseconds
public boolean setFullMilliseconds(long milliseconds)
Set the fullTimeSpanin terms of milliseconds.- Parameters:
milliseconds- The number of milliseconds.- Returns:
false, ifmilliseconds < 0;true, else.
-
getFullMilliseconds
public long getFullMilliseconds()
Get the length of theTimeSpanas milliseconds.- Returns:
- The number of milliseconds, if known.
-1, else (e.g., when theTimeSpanis not instantiated).
-
getYears
public int getYears()
Get the year fraction of this object.- Returns:
-1, if this object is not instantiated; the year fraction, else.
-
getDays
public int getDays()
Get the day fraction of this object.- Returns:
-1, if this object is not instantiated; the day fraction, else.
-
getHours
public int getHours()
Get the hour fraction of this object.- Returns:
-1, if this object is not instantiated; the hour fraction, else.
-
getMinutes
public int getMinutes()
Get the minute fraction of this object.- Returns:
-1, if this object is not instantiated; the minute fraction, else.
-
getSeconds
public int getSeconds()
Get the second fraction of this object.- Returns:
-1, if this object is not instantiated; the second fraction, else.
-
getMilliseconds
public int getMilliseconds()
Get the millisecond fraction of this object.- Returns:
-1, if this object is not instantiated; the millisecond fraction, else.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- String representation of object. See class comments.
-
ensureAll
private void ensureAll()
-
ensureFull
private void ensureFull()
-
-