ilog.views.gantt
Class IlvDuration

java.lang.Object
  extended by ilog.views.gantt.IlvDuration
All Implemented Interfaces:
Serializable, Comparable

public class IlvDuration
extends Object
implements Serializable, Comparable

IlvDuration represents a relative time period, with millisecond precision. IlvDuration is an immutable class with value semantics.

See Also:
Serialized Form

Field Summary
static IlvDuration ONE_DAY
          A duration of 1 day.
static long ONE_DAY_MILLIS
          The number of milliseconds in 1 day.
static IlvDuration ONE_HOUR
          A duration of 1 hour.
static long ONE_HOUR_MILLIS
          The number of milliseconds in 1 hour.
static IlvDuration ONE_MINUTE
          A duration of 1 minute.
static long ONE_MINUTE_MILLIS
          The number of milliseconds in 1 minute.
static IlvDuration ONE_SECOND
          A duration of 1 second.
static long ONE_SECOND_MILLIS
          The number of milliseconds in 1 second.
static IlvDuration ONE_WEEK
          A duration of 1 week.
static long ONE_WEEK_MILLIS
          The number of milliseconds in 1 week.
 
Constructor Summary
IlvDuration(long millis)
          Creates an IlvDuration that represents the specified number of milliseconds.
 
Method Summary
 Date add(Date t)
          Returns a new Date that is the sum of the specified time and this duration.
 IlvDuration add(IlvDuration delta)
          Returns a new IlvDuration that is the sum of this duration and the specified duration.
 int compareTo(IlvDuration anotherDuration)
          Returns the result of comparing this duration to the specified duration.
 int compareTo(Object o)
          Returns the result of comparing this duration to another object.
 IlvDuration divide(double divisor)
          Returns a new IlvDuration that is the result of dividing this duration by the specified amount.
 IlvDuration divide(int divisor)
          Returns a new IlvDuration that is the result of dividing this duration by the specified amount.
 boolean equals(Object obj)
          Returns whether an object is logically equal to this duration.
 long getMillis()
          Returns the number of milliseconds that this duration represents.
 int hashCode()
          Returns a hashcode for this duration.
 IlvDuration multiply(double multiplier)
          Returns a new IlvDuration that is the result of multiplying this duration by the specified amount.
 IlvDuration multiply(int multiplier)
          Returns a new IlvDuration that is the result of multiplying this duration by the specified amount.
 IlvDuration subtract(IlvDuration delta)
          Returns a new IlvDuration that is the difference between this duration and the specified duration.
 String toString()
          Returns a string representation of this duration.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ONE_SECOND_MILLIS

public static final long ONE_SECOND_MILLIS
The number of milliseconds in 1 second.

See Also:
Constant Field Values

ONE_MINUTE_MILLIS

public static final long ONE_MINUTE_MILLIS
The number of milliseconds in 1 minute.

See Also:
Constant Field Values

ONE_HOUR_MILLIS

public static final long ONE_HOUR_MILLIS
The number of milliseconds in 1 hour.

See Also:
Constant Field Values

ONE_DAY_MILLIS

public static final long ONE_DAY_MILLIS
The number of milliseconds in 1 day.

See Also:
Constant Field Values

ONE_WEEK_MILLIS

public static final long ONE_WEEK_MILLIS
The number of milliseconds in 1 week.

See Also:
Constant Field Values

ONE_SECOND

public static final IlvDuration ONE_SECOND
A duration of 1 second.


ONE_MINUTE

public static final IlvDuration ONE_MINUTE
A duration of 1 minute.


ONE_HOUR

public static final IlvDuration ONE_HOUR
A duration of 1 hour.


ONE_DAY

public static final IlvDuration ONE_DAY
A duration of 1 day.


ONE_WEEK

public static final IlvDuration ONE_WEEK
A duration of 1 week.

Constructor Detail

IlvDuration

public IlvDuration(long millis)
Creates an IlvDuration that represents the specified number of milliseconds.

Parameters:
millis - The number of milliseconds.
Method Detail

getMillis

public long getMillis()
Returns the number of milliseconds that this duration represents.


add

public Date add(Date t)
Returns a new Date that is the sum of the specified time and this duration.

Parameters:
t - The time to add to this duration.

add

public IlvDuration add(IlvDuration delta)
Returns a new IlvDuration that is the sum of this duration and the specified duration.

Parameters:
delta - The duration to add to this duration.

subtract

public IlvDuration subtract(IlvDuration delta)
Returns a new IlvDuration that is the difference between this duration and the specified duration.

Parameters:
delta - The duration to subtract from this duration.

multiply

public IlvDuration multiply(int multiplier)
Returns a new IlvDuration that is the result of multiplying this duration by the specified amount.

Parameters:
multiplier - The amount to multiply this duration by.

multiply

public IlvDuration multiply(double multiplier)
Returns a new IlvDuration that is the result of multiplying this duration by the specified amount.

Parameters:
multiplier - The amount to multiply this duration by.
Since:
JViews 3.5

divide

public IlvDuration divide(int divisor)
Returns a new IlvDuration that is the result of dividing this duration by the specified amount.

Parameters:
divisor - The amount to divide this duration by.

divide

public IlvDuration divide(double divisor)
Returns a new IlvDuration that is the result of dividing this duration by the specified amount.

Parameters:
divisor - The amount to divide this duration by.
Since:
JViews 3.5

equals

public boolean equals(Object obj)
Returns whether an object is logically equal to this duration. The result will be true if and only if the argument is an IlvDuration object that represents the same length of time as this duration.

Overrides:
equals in class Object
Parameters:
obj - The object to compare with.
Returns:
true if the objects are the same; false otherwise.

compareTo

public int compareTo(IlvDuration anotherDuration)
Returns the result of comparing this duration to the specified duration.

Parameters:
anotherDuration - The duration to be compared to this one.
Returns:
A negative integer, zero, or a positive integer depending on whether this duration is less than, equal to, or greater than the specified duration.
Since:
JViews 3.5

compareTo

public int compareTo(Object o)
Returns the result of comparing this duration to another object. If the object is an IlvDuration, this function behaves like compareTo(IlvDuration). Otherwise, it throws a ClassCastException because IlvDuration objects are comparable only to other IlvDuration objects.

Specified by:
compareTo in interface Comparable
Parameters:
o - The object to be compared.
Returns:
A negative integer, zero, or a positive integer depending on whether this duration is less than, equal to, or greater than the specified duration.
Throws:
ClassCastException - if the argument is not an IlvDuration.
Since:
JViews 6.0

hashCode

public int hashCode()
Returns a hashcode for this duration. The result is the exclusive OR of the two halves of the primitive long value returned by the getMillis() method. That is, the hash code is the value of the expression:
 (int)(this.getMillis()^(this.getMillis() >>> 32))

Overrides:
hashCode in class Object
Returns:
A hash code value for this object.
Since:
JViews 3.5

toString

public String toString()
Returns a string representation of this duration.

Overrides:
toString in class Object
Since:
JViews 3.5


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.