com.alachisoft.jvcache.runtime.util
Class TimeSpan

java.lang.Object
  extended by com.alachisoft.jvcache.runtime.util.TimeSpan
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<TimeSpan>

public class TimeSpan
extends java.lang.Object
implements java.lang.Comparable<TimeSpan>, java.io.Serializable

TimeSpan class is similiar to .Net System.TimeSpan. Though this class delivers minimal funcitonality that is required to specify "TimeSpan" value. It is used in giving SlidingExpiration value while adding data in NCache.

See Also:
Serialized Form

Field Summary
static TimeSpan ZERO
           
 
Constructor Summary
TimeSpan()
          Default Constructor: Initializes a new TimeSpan with zero time span.
TimeSpan(int miliseconds)
          Summary: Initializes a new TimeSpan to the specified number of miliseconds.
TimeSpan(int minutes, int seconds)
          Summary: Initializes a new System.TimeSpan to a specified number of minutes and seconds.
TimeSpan(int hours, int minutes, int seconds)
          Summary: Initializes a new System.TimeSpan to a specified number of hours, minutes and seconds.
TimeSpan(long ticks)
          Summary: Initializes a new System.TimeSpan to a specified number of ticks..
 
Method Summary
 int compareTo(TimeSpan obj)
           
 boolean equals(java.lang.Object object)
           
 long getTotalMiliSeconds()
          Summary: This method calculated total miliseconds for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in miliseconds.
 long getTotalMinutes()
           
 long getTotalSeconds()
           
 long getTotalTicks()
          Summary: This method calculates total ticks for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in ticks.
 int hashCode()
           
 void setHours(int hours)
          Summary: Sets value of hours for this instance of TimeSpan.
 void setMiliSeconds(int miliseconds)
          Summary: Sets value of miliseconds for this instance of TimeSpan.
 void setMinutes(int minutes)
          Summary: Sets value of minutes for this instance of TimeSpan.
 void setSeconds(int seconds)
          Summary: Sets value of seconds for this instance of TimeSpan.
static TimeSpan Subtract(java.util.Date from, java.util.Date to)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static TimeSpan ZERO
Constructor Detail

TimeSpan

public TimeSpan()
Default Constructor: Initializes a new TimeSpan with zero time span.


TimeSpan

public TimeSpan(int miliseconds)
Summary: Initializes a new TimeSpan to the specified number of miliseconds.

Parameters:
miliseconds - A time period expressed in miliseconds units.

TimeSpan

public TimeSpan(int minutes,
                int seconds)
Summary: Initializes a new System.TimeSpan to a specified number of minutes and seconds.

Parameters:
minutes - Number of minutes.
seconds - Number of seconds.

TimeSpan

public TimeSpan(int hours,
                int minutes,
                int seconds)
Summary: Initializes a new System.TimeSpan to a specified number of hours, minutes and seconds.

Parameters:
hours - Number of hours.
minutes - Number of minutes.
seconds - Number of seconds.

TimeSpan

public TimeSpan(long ticks)
Summary: Initializes a new System.TimeSpan to a specified number of ticks..

Parameters:
ticks - A time period expressed in 100-nanosecond units. If ticks value is passed, it overrides other values specified through hours,minutes,seconds,miliseconds
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.
Method Detail

compareTo

public int compareTo(TimeSpan obj)
Specified by:
compareTo in interface java.lang.Comparable<TimeSpan>

Subtract

public static TimeSpan Subtract(java.util.Date from,
                                java.util.Date to)
                         throws ArgumentException
Parameters:
from -
to -
Returns:
Throws:
ArgumentException

setHours

public void setHours(int hours)
Summary: Sets value of hours for this instance of TimeSpan.

Parameters:
hours - A time period expressed in hours.
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.

setMinutes

public void setMinutes(int minutes)
Summary: Sets value of minutes for this instance of TimeSpan.

Parameters:
minutes - A time period expressed in minutes.
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.

setSeconds

public void setSeconds(int seconds)
Summary: Sets value of seconds for this instance of TimeSpan.

Parameters:
seconds - A time period expressed in seconds.
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.

setMiliSeconds

public void setMiliSeconds(int miliseconds)
Summary: Sets value of miliseconds for this instance of TimeSpan.

Parameters:
miliseconds -
Throws:
java.lang.IllegalArgumentException - The parameters specify a System.TimeSpan value is not positive or out of range.

getTotalMiliSeconds

public long getTotalMiliSeconds()
Summary: This method calculated total miliseconds for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in miliseconds. Ticks are not used in computing this value.

Returns:
Total number of miliseconds represented by this instance of TimeSpan. If negative value is calculated, zero is returned.

getTotalMinutes

public long getTotalMinutes()
Returns:

getTotalSeconds

public long getTotalSeconds()
Returns:

getTotalTicks

public long getTotalTicks()
Summary: This method calculates total ticks for this instance of TimeSpan.This includes hours + minutes + seconds + miliseconds computed in ticks. In case ticks value is explicitly set, value is not computed instead original ticks value is returned.

Returns:
Total number of ticks represented by this instance of TimeSpan. If negative value is calculated, zero is returned.

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object