com.starteam.util
Class TimeSpan

java.lang.Object
  extended by com.starteam.util.TimeSpan
All Implemented Interfaces:
java.io.Serializable

public final class TimeSpan
extends java.lang.Object
implements java.io.Serializable

The amount of time between two DateTimes.

See Also:
Serialized Form

Field Summary
static TimeSpan MAX_VALUE
          The largest value of a TimeSpan (DoubleProperty.MAX_VALUE)
static TimeSpan MIN_VALUE
          The smallest value of a TimeSpan (DoubleProperty.MIN_VALUE)
static TimeSpan ZERO
          A TimeSpan of value 0.0
 
Method Summary
 TimeSpan add(TimeSpan b)
          returns a TimeSpan composed from the addition of a TimeSpan to this instance
static TimeSpan add(TimeSpan a, TimeSpan b)
          returns a TimeSpan created from the addition of 2 Timespan instances
static int compare(TimeSpan a, TimeSpan b)
          returns the result of a comparison between two TimeSpan's
 int compareTo(TimeSpan b)
          compares a TimeSpan to this instance
 TimeSpan duration()
          returns the real duration in time for this TimeSpan, i.e.
 boolean equals(java.lang.Object obj)
          Compare this TimeSpan to another one.
static TimeSpan fromDays(double days)
          returns a time span created from a specified number of days
static TimeSpan fromDays(int days, int hrs, int min, int sec)
          returns a TimeSpan created from the specified number of days, hours, minutes and seconds
static TimeSpan fromDays(int days, int hrs, int min, int sec, int msec)
          returns a TimeSpan created from the specified number of days, hours, minutes, seconds and milliseconds
static TimeSpan fromHours(double hours)
          returns a time span created from a specified number of hours
static TimeSpan fromHours(int hrs, int min, int sec)
          returns a TimeSpan created from the specified number of hours, minutes and seconds
static TimeSpan fromHours(int hrs, int min, int sec, int msec)
          returns a TimeSpan created from the specified number of hours, minutes, seconds and milliseconds
static TimeSpan fromMilliseconds(double milliseconds)
          returns a time span created from a specified number of milliseconds
static TimeSpan fromMinutes(double minutes)
          returns a time span created from a specified number of minutes
static TimeSpan fromMonths(double months)
          returns a time span created from a specified number of months
static TimeSpan fromSeconds(double seconds)
          returns a time span created from a specified number of seconds
static TimeSpan fromTicks(long ticks)
          returns a time span created from a specified number of ticks
static TimeSpan fromWeeks(double weeks)
          returns a time span created from a specified number of weeks
static TimeSpan fromYears(double years)
          returns a time span created from a specified number of years
 int getDaysPart()
          returns the number of whole (24 hour) days in this TimeSpan
 int getHoursPart()
          returns the number of whole hours in this TimeSpan
 int getMillisecondsPart()
          returns the number of whole milliseconds in this TimeSpan
 int getMinutesPart()
          returns the number of whole minutes in this TimeSpan
 int getSecondsPart()
          returns the number of whole seconds in this TimeSpan
 int hashCode()
          Gets a unique hash for this TimeSpan
 boolean isEqualTo(TimeSpan t)
          Compare this TimeSpan to another one.
 TimeSpan negate()
          returns a TimeSpan composed by subtracting this TimeSpan instance from ZERO
static TimeSpan parse(java.lang.String timespan)
          Returns a TimeSpan composed by parsing the specified String representation.
 TimeSpan subtract(TimeSpan b)
          returns a TimeSpan composed from the subtraction of a TimeSpan from this instance
static TimeSpan subtract(TimeSpan a, TimeSpan b)
          returns a TimeSpan created from the subtraction of 2 Timespan instances
 double toDays()
          returns the number of days in this TimeSpan
 double toHours()
          returns the number of hours in this TimeSpan
 double toMilliseconds()
          returns the number of milliseconds in this TimeSpan
 double toMinutes()
          returns the number of minutes in this TimeSpan
 double toMonths()
          returns the number of months in this TimeSpan in 30 day increments.
 double toSeconds()
          returns the number of seconds in this TimeSpan
 java.lang.String toString()
          returns a string representation of this instance in the form "[-][d.]hh:mm:ss[.ff]"
 long toTicks()
          returns the number of ticks in this TimeSpan (a tick is 100 nanoseconds)
 double toWeeks()
          returns the number of weeks in this TimeSpan
 double toYears()
          returns the number of years in this TimeSpan in 365 day increments.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final TimeSpan MIN_VALUE
The smallest value of a TimeSpan (DoubleProperty.MIN_VALUE)


MAX_VALUE

public static final TimeSpan MAX_VALUE
The largest value of a TimeSpan (DoubleProperty.MAX_VALUE)


ZERO

public static final TimeSpan ZERO
A TimeSpan of value 0.0

Method Detail

add

public static TimeSpan add(TimeSpan a,
                           TimeSpan b)
returns a TimeSpan created from the addition of 2 Timespan instances

Parameters:
a - TimeSpan
b - TimeSpan
Returns:
a TimeSpan created from the addition of 2 Timespan instances

subtract

public static TimeSpan subtract(TimeSpan a,
                                TimeSpan b)
returns a TimeSpan created from the subtraction of 2 Timespan instances

Parameters:
a - TimeSpan
b - TimeSpan
Returns:
TimeSpan

fromYears

public static TimeSpan fromYears(double years)
returns a time span created from a specified number of years

Parameters:
years - double (in 365 day increments). This transformation may be lossy
Returns:
a time span created from a specified number of years

fromMonths

public static TimeSpan fromMonths(double months)
returns a time span created from a specified number of months

Parameters:
months - double (in 30 day increments). This transformation may be lossy
Returns:
a time span created from a specified number of months

fromWeeks

public static TimeSpan fromWeeks(double weeks)
returns a time span created from a specified number of weeks

Parameters:
weeks - double (in 7 day increments)
Returns:
a time span created from a specified number of weeks

fromDays

public static TimeSpan fromDays(double days)
returns a time span created from a specified number of days

Parameters:
days - double
Returns:
a time span created from a specified number of days

fromHours

public static TimeSpan fromHours(double hours)
returns a time span created from a specified number of hours

Parameters:
hours - double
Returns:
a time span created from a specified number of hours

fromMinutes

public static TimeSpan fromMinutes(double minutes)
returns a time span created from a specified number of minutes

Parameters:
minutes - double
Returns:
a time span created from a specified number of minutes

fromSeconds

public static TimeSpan fromSeconds(double seconds)
returns a time span created from a specified number of seconds

Parameters:
seconds - double
Returns:
a time span created from a specified number of seconds

fromMilliseconds

public static TimeSpan fromMilliseconds(double milliseconds)
returns a time span created from a specified number of milliseconds

Parameters:
milliseconds - double
Returns:
a time span created from a specified number of milliseconds

fromTicks

public static TimeSpan fromTicks(long ticks)
returns a time span created from a specified number of ticks

Parameters:
ticks - long (1 tick = 100 nanosecs)
Returns:
a time span created from a specified number of ticks

fromHours

public static TimeSpan fromHours(int hrs,
                                 int min,
                                 int sec)
returns a TimeSpan created from the specified number of hours, minutes and seconds

Parameters:
hrs - int
min - int
sec - int
Returns:
a TimeSpan created from the specified number of hours, minutes and seconds

fromHours

public static TimeSpan fromHours(int hrs,
                                 int min,
                                 int sec,
                                 int msec)
returns a TimeSpan created from the specified number of hours, minutes, seconds and milliseconds

Parameters:
hrs - int
min - int
sec - int
msec - int
Returns:
a TimeSpan created from the specified number of hours, minutes, seconds and milliseconds

fromDays

public static TimeSpan fromDays(int days,
                                int hrs,
                                int min,
                                int sec)
returns a TimeSpan created from the specified number of days, hours, minutes and seconds

Parameters:
days - int
hrs - int
min - int
sec - int
Returns:
a TimeSpan created from the specified number of days, hours, minutes and seconds

fromDays

public static TimeSpan fromDays(int days,
                                int hrs,
                                int min,
                                int sec,
                                int msec)
returns a TimeSpan created from the specified number of days, hours, minutes, seconds and milliseconds

Parameters:
days - int
hrs - int
min - int
sec - int
msec - int
Returns:
a TimeSpan created from the specified number of days, hours, minutes, seconds and milliseconds

toYears

public double toYears()
returns the number of years in this TimeSpan in 365 day increments. This transformation may be lossy

Returns:
the number of years in this TimeSpan

toMonths

public double toMonths()
returns the number of months in this TimeSpan in 30 day increments. This transformation may be lossy

Returns:
the number of months in this TimeSpan

toWeeks

public double toWeeks()
returns the number of weeks in this TimeSpan

Returns:
the number of weeks in this TimeSpan

toDays

public double toDays()
returns the number of days in this TimeSpan

Returns:
the number of days in this TimeSpan

toHours

public double toHours()
returns the number of hours in this TimeSpan

Returns:
the number of hours in this TimeSpan

toMinutes

public double toMinutes()
returns the number of minutes in this TimeSpan

Returns:
the number of minutes in this TimeSpan

toSeconds

public double toSeconds()
returns the number of seconds in this TimeSpan

Returns:
the number of seconds in this TimeSpan

toMilliseconds

public double toMilliseconds()
returns the number of milliseconds in this TimeSpan

Returns:
the number of milliseconds in this TimeSpan

toTicks

public long toTicks()
returns the number of ticks in this TimeSpan (a tick is 100 nanoseconds)

Returns:
the number of ticks in this TimeSpan

getDaysPart

public int getDaysPart()
returns the number of whole (24 hour) days in this TimeSpan

Returns:
the number of whole (24 hour) days in this TimeSpan

getHoursPart

public int getHoursPart()
returns the number of whole hours in this TimeSpan

Returns:
the number of whole hours in this TimeSpan

getMinutesPart

public int getMinutesPart()
returns the number of whole minutes in this TimeSpan

Returns:
the number of whole minutes in this TimeSpan

getSecondsPart

public int getSecondsPart()
returns the number of whole seconds in this TimeSpan

Returns:
the number of whole seconds in this TimeSpan

getMillisecondsPart

public int getMillisecondsPart()
returns the number of whole milliseconds in this TimeSpan

Returns:
the number of whole milliseconds in this TimeSpan

add

public TimeSpan add(TimeSpan b)
returns a TimeSpan composed from the addition of a TimeSpan to this instance

Parameters:
b - the TimeSpan to add to this instance
Returns:
a TimeSpan composed from the addition of a TimeSpan to this instance

subtract

public TimeSpan subtract(TimeSpan b)
returns a TimeSpan composed from the subtraction of a TimeSpan from this instance

Parameters:
b - the TimeSpan to subtract from this instance
Returns:
a TimeSpan composed from the subtraction of a TimeSpan from this instance

compare

public static int compare(TimeSpan a,
                          TimeSpan b)
returns the result of a comparison between two TimeSpan's

Parameters:
a - TimeSpan
b - TimeSpan
Returns:
0, 1, or -1

compareTo

public int compareTo(TimeSpan b)
compares a TimeSpan to this instance

Parameters:
b - TimeSpan
Returns:
0, 1 or -1

negate

public TimeSpan negate()
returns a TimeSpan composed by subtracting this TimeSpan instance from ZERO

Returns:
a TimeSpan composed by subtracting this TimeSpan instance from ZERO

duration

public TimeSpan duration()
returns the real duration in time for this TimeSpan, i.e. the 'modulus' of this TimeSpan

Returns:
the real duration in time for this TimeSpan as a positive TimeSpan

toString

public java.lang.String toString()
returns a string representation of this instance in the form "[-][d.]hh:mm:ss[.ff]"

Overrides:
toString in class java.lang.Object
Returns:
a default string representation of this instance
See Also:
TimeSpanFormatter.format(TimeSpan)

parse

public static TimeSpan parse(java.lang.String timespan)
Returns a TimeSpan composed by parsing the specified String representation. The format of the "timespan" parameter is: [ws][-][d.|d ]hh:mm:ss[.ff][ws], where items in brackets are optional and the minus sign, period and colon are literal values. The meaning of each part is given below: ws - optional whitespace. d - optional days. Note that if present, this must be followed by either a period or a space. hh - hours, ranging from 0 to 23. mm - minutes, ranging from 0 to 59. ss - seconds, ranging from 0 to 59. ff - optional fraction of a second in milliseconds, from 1 to 7 decimal digits.

Parameters:
timespan - a String representation of a TimeSpan
Returns:
a new TimeSpan instance or null if the string cannot be parsed

isEqualTo

public boolean isEqualTo(TimeSpan t)
Compare this TimeSpan to another one.

Parameters:
t - The TimeSpan to be compared to this one.
Returns:
true if the two TimeSpans have the same value, and false otherwise.

equals

public boolean equals(java.lang.Object obj)
Compare this TimeSpan to another one.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The TimeSpan to be compared to this one.
Returns:
true if the two TimeSpans have the same value, and false otherwise.

hashCode

public int hashCode()
Gets a unique hash for this TimeSpan

Overrides:
hashCode in class java.lang.Object
Returns:
A unique hash for this TimeSpan


StarTeam SDK 14.0, Build 21
Copyright © 2003-2012 Borland Software Corporation. All rights reserved.