|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.melloware.jukes.util.TimeSpan
public class TimeSpan
The value of an instance of TimeSpan represents a period of time. TimeSpan can be used in several ways. To calculate the difference in time between two dates:
TimeSpan timespan = TimeSpan.subtract(date1, date2);To add five days to a TimeSpan:
timspan.add(TimeSpanUnit.DAYS, 5);To subtract another TimeSpan object from this one:
timspan.subtract(timespan2);
| Field Summary | |
|---|---|
static TimeSpan |
MAX_VALUE
Represents the Maximum TimeSpan value |
static TimeSpan |
MIN_VALUE
Represents the Minimum TimeSpan value |
static TimeSpan |
ZERO
Represents the TimeSpan with a value of zero |
| Constructor Summary | |
|---|---|
TimeSpan(long time)
Creates a new instance of TimeSpan based on the number of milliseconds entered. |
|
TimeSpan(TimeSpanUnit unit,
long value)
Creates a new TimeSpan object based on the unit and value entered. |
|
| Method Summary | |
|---|---|
void |
add(TimeSpan timespan)
Adds a TimeSpan to this TimeSpan. |
void |
add(TimeSpanUnit unit,
long value)
Adds a number of units to this TimeSpan. |
java.lang.Object |
clone()
Returns a clone of this TimeSpan. |
static int |
compare(TimeSpan first,
TimeSpan second)
Compares two TimeSpan objects. |
int |
compareTo(java.lang.Object o)
Compares this object with the specified object for order. |
TimeSpan |
duration()
Returns a TimeSpan whose value is the absolute value of this TimeSpan. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. |
long |
getDays()
Gets the number of days (truncated). |
long |
getHours()
Gets the number of hours (truncated). |
long |
getMilliseconds()
Gets the number of milliseconds. |
long |
getMinutes()
Gets the number of minutes (truncated). |
java.lang.String |
getMusicDuration()
Returns a string for music formatting for album length. |
long |
getSeconds()
Gets the number of seconds (truncated). |
long |
getTime()
Gets the time. |
double |
getTotalDays()
Gets the number of days including fractional days. |
double |
getTotalHours()
Gets the number of hours including fractional hours. |
double |
getTotalMinutes()
Gets the number of minutes including fractional minutes. |
double |
getTotalSeconds()
Gets the number of seconds including fractional seconds. |
int |
hashCode()
Returns a hash code value for the object. |
boolean |
isNegative()
Indicates whether the value of the TimeSpan is negative. |
boolean |
isPositive()
Indicates whether the value of the TimeSpan is positive. |
boolean |
isZero()
Indicates whether the value of the TimeSpan is zero. |
TimeSpan |
negate()
Returns a TimeSpan whose value is the negated value of this TimeSpan. |
void |
setTime(long aTime)
Sets the time. |
static TimeSpan |
subtract(java.util.Date date1,
java.util.Date date2)
Subtracts two Date objects creating a new TimeSpan object. |
void |
subtract(TimeSpan timespan)
Subtracts a TimeSpan from this TimeSpan. |
void |
subtract(TimeSpanUnit unit,
long value)
Subtracts a number of units from this TimeSpan. |
java.lang.String |
toString()
Returns a string representation of the object in the format "[-]d.hh:mm:ss.ff" where "-" is an optional sign for negative TimeSpan values, the "d" component is days, "hh" is hours, "mm" is minutes, "ss" is seconds, and "ff" is milliseconds |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final TimeSpan MAX_VALUE
public static final TimeSpan MIN_VALUE
public static final TimeSpan ZERO
| Constructor Detail |
|---|
public TimeSpan(long time)
time - the number of milliseconds for this TimeSpan.
public TimeSpan(TimeSpanUnit unit,
long value)
unit - the type of unit to use to create a TimeSpan instance.value - the number of units to use to create a TimeSpan instance.| Method Detail |
|---|
public static int compare(TimeSpan first,
TimeSpan second)
first - first TimeSpan to use in the compare.second - second TimeSpan to use in the compare.
public static TimeSpan subtract(java.util.Date date1,
java.util.Date date2)
date1 - Date to use as the base value.date2 - Date to subtract from the base value.
public long getDays()
public long getHours()
public long getMilliseconds()
public long getMinutes()
public java.lang.String getMusicDuration()
public long getSeconds()
public double getTotalDays()
public double getTotalHours()
public double getTotalMinutes()
public double getTotalSeconds()
public boolean isNegative()
true if the value of the TimeSpan is less
than zero.
false otherwise.public boolean isPositive()
true if the value of the TimeSpan is greater
than zero.
false otherwise.public boolean isZero()
true if the value of the TimeSpan is equal to zero.
false otherwise.public void add(TimeSpan timespan)
timespan - the TimeSpan to add to this TimeSpan.
public void add(TimeSpanUnit unit,
long value)
unit - the type of unit to add to this TimeSpan.value - the number of units to add to this TimeSpan.public java.lang.Object clone()
clone in class java.lang.Objectpublic int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - the Object to be compared.
java.lang.ClassCastException - if the specified object's type prevents it
from being compared to this Object.public TimeSpan duration()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the reference object with which to compare.
true if the obj argument is a TimeSpan object
with the exact same number of milliseconds.
false otherwise.public int hashCode()
java.util.Hashtable. The method uses the same
algorithm as found in the Long class.
hashCode in class java.lang.ObjectObject.equals(java.lang.Object),
Hashtablepublic TimeSpan negate()
public void subtract(TimeSpan timespan)
timespan - the TimeSpan to subtract from this TimeSpan.
public void subtract(TimeSpanUnit unit,
long value)
unit - the type of unit to subtract from this TimeSpan.value - the number of units to subtract from this TimeSpan.public java.lang.String toString()
toString in class java.lang.Objectpublic long getTime()
public void setTime(long aTime)
aTime - The time to set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||