Package com.aspose.tasks
Class TimeDelta
- java.lang.Object
-
- com.aspose.tasks.TimeDelta
-
public class TimeDelta extends Object
Represents a difference between two timestamps.
-
-
Constructor Summary
Constructors Constructor Description TimeDelta(int hours, int minutes, int seconds)
Initializes new instance of TimeDelta to the specified number of hours, minutes and seconds.TimeDelta(int days, int hours, int minutes, int seconds, int milliseconds)
Initializes new instance of TimeDelta to the specified number of days, hours, minutes, seconds and milliseconds.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TimeDelta
add(TimeDelta other)
Returns a new TimeDelta object whose value is a sum of this and other instance.Object
clone()
static int
compare(TimeDelta t1, TimeDelta t2)
Compares two TimeDelta values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.int
compareTo(TimeDelta other)
Compares this instance to a specified TimeDelta object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the TimeSpan object.boolean
equals(TimeDelta other)
Indicates whether some `other` time span is equal to this one.static boolean
equals(TimeDelta t1, TimeDelta t2)
Checks two instances for equality.boolean
equals(Object other)
static TimeDelta
fromDays(double value)
Returns a TimeDelta that represents a specified number of days (rounded to the nearest millisecond).static TimeDelta
fromHours(double value)
Returns a TimeDelta that represents a specified number of hours (rounded to the nearest millisecond).static TimeDelta
fromMilliseconds(double value)
Returns a TimeDelta that represents a specified number of milliseconds (rounded to the nearest millisecond).static TimeDelta
fromMinutes(double value)
Returns a TimeDelta that represents a specified number of minutes (rounded to the nearest millisecond).static TimeDelta
fromSeconds(double value)
Returns a TimeDelta that represents a specified number of seconds (rounded to the nearest millisecond).int
getDays()
Returns the days component of the time interval, represented by this instance.int
getHours()
Returns the hours component of the time interval, represented by this instance.int
getMilliseconds()
Returns the milliseconds component of the time interval, represented by this instance.int
getMinutes()
Returns the minutes component of the time interval, represented by this instance.int
getSeconds()
Returns the seconds component of the time interval, represented by this instance.double
getTotalDays()
Returns the value of the current instance expressed in whole and fractional days.double
getTotalHours()
Returns the value of the current instance expressed in whole and fractional hours.double
getTotalMilliseconds()
Returns the value of the current instance expressed in whole and fractional milliseconds.double
getTotalMinutes()
Returns the value of the current instance expressed in whole and fractional minutes.double
getTotalSeconds()
Returns the value of the current instance expressed in whole and fractional seconds.int
hashCode()
TimeDelta
negate()
Returns a new `TimeDelta` whose value is the negated value of this instance.static TimeDelta
parse(String s)
Converts the string representation of a time interval to its `TimeDelta` equivalent.TimeDelta
subtract(TimeDelta other)
Returns a new TimeDelta object whose value is a difference between this and `other` instances.String
toString()
static boolean
tryParse(String s, TimeDelta[] result)
Converts the string representation of a time interval to its TimeDelta equivalent and returns a value that indicates whether the conversion succeeded.
-
-
-
Constructor Detail
-
TimeDelta
public TimeDelta(int hours, int minutes, int seconds)
Initializes new instance of TimeDelta to the specified number of hours, minutes and seconds.- Parameters:
hours
- number of hours.minutes
- number of minutes.seconds
- number of seconds.
-
TimeDelta
public TimeDelta(int days, int hours, int minutes, int seconds, int milliseconds)
Initializes new instance of TimeDelta to the specified number of days, hours, minutes, seconds and milliseconds.- Parameters:
days
- number of days.hours
- number of hours.minutes
- number of minutes.seconds
- number of seconds.milliseconds
- number of milliseconds.
-
-
Method Detail
-
getDays
public int getDays()
Returns the days component of the time interval, represented by this instance.- Returns:
- the days component of the time inteval. Can be positive or negative.
-
getHours
public int getHours()
Returns the hours component of the time interval, represented by this instance.- Returns:
- the hours component of the time interval in range from -23 through 23.
-
getMilliseconds
public int getMilliseconds()
Returns the milliseconds component of the time interval, represented by this instance.- Returns:
- the milliseconds component of the time interval in range from -999 through 999.
-
getMinutes
public int getMinutes()
Returns the minutes component of the time interval, represented by this instance.- Returns:
- the minutes component of the time interval in range from -59 through 59.
-
getSeconds
public int getSeconds()
Returns the seconds component of the time interval, represented by this instance.- Returns:
- the seconds component of the time interval in range from -59 through 59.
-
getTotalDays
public double getTotalDays()
Returns the value of the current instance expressed in whole and fractional days.- Returns:
- the total number of days represented by this instance.
-
getTotalHours
public double getTotalHours()
Returns the value of the current instance expressed in whole and fractional hours.- Returns:
- the total number of hours represented by this instance.
-
getTotalMilliseconds
public double getTotalMilliseconds()
Returns the value of the current instance expressed in whole and fractional milliseconds.- Returns:
- the total number of milliseconds represented by this instance.
-
getTotalMinutes
public double getTotalMinutes()
Returns the value of the current instance expressed in whole and fractional minutes.- Returns:
- the total number of minutes represented by this instance.
-
getTotalSeconds
public double getTotalSeconds()
Returns the value of the current instance expressed in whole and fractional seconds.- Returns:
- the total number of seconds represented by this instance.
-
add
public TimeDelta add(TimeDelta other)
Returns a new TimeDelta object whose value is a sum of this and other instance.- Parameters:
other
- the instance to sum with.- Returns:
- a new object that represents the value of this instance plus value of other instance.
-
compare
public static int compare(TimeDelta t1, TimeDelta t2)
Compares two TimeDelta values and returns an integer that indicates whether the first value is shorter than, equal to, or longer than the second value.- Parameters:
t1
- the first time interval to compare.t2
- the second time interval to compare.- Returns:
- -1 if `t1` is shorter than `t2`, 0 if `t1` equals to `t2` and 1 if `t1` is longer than `t2`.
-
compareTo
public int compareTo(TimeDelta other)
Compares this instance to a specified TimeDelta object and returns an integer that indicates whether this instance is shorter than, equal to, or longer than the TimeSpan object.- Parameters:
other
- an instance to compare with.- Returns:
- -1 if this instance is shorter than `other`, 0 if this instance equals to `other` and 1 if this instance is longer than `other`.
-
equals
public static boolean equals(TimeDelta t1, TimeDelta t2)
Checks two instances for equality.- Parameters:
t1
- first instance.t2
- second instance.- Returns:
- `true` if instances are equal; `false` otherwise.
-
fromDays
public static TimeDelta fromDays(double value)
Returns a TimeDelta that represents a specified number of days (rounded to the nearest millisecond).- Parameters:
value
- a number of days.- Returns:
- an object that represents `value`.
-
fromHours
public static TimeDelta fromHours(double value)
Returns a TimeDelta that represents a specified number of hours (rounded to the nearest millisecond).- Parameters:
value
- a number of hours.- Returns:
- an object that represents `value`.
-
fromMinutes
public static TimeDelta fromMinutes(double value)
Returns a TimeDelta that represents a specified number of minutes (rounded to the nearest millisecond).- Parameters:
value
- a number of minutes.- Returns:
- an object that represents `value`.
-
fromSeconds
public static TimeDelta fromSeconds(double value)
Returns a TimeDelta that represents a specified number of seconds (rounded to the nearest millisecond).- Parameters:
value
- a number of seconds.- Returns:
- an object that represents `value`.
-
fromMilliseconds
public static TimeDelta fromMilliseconds(double value)
Returns a TimeDelta that represents a specified number of milliseconds (rounded to the nearest millisecond).- Parameters:
value
- a number of milliseconds.- Returns:
- an object that represents `value`.
-
negate
public TimeDelta negate()
Returns a new `TimeDelta` whose value is the negated value of this instance.- Returns:
- A new object with the same numeric value as this instance, but with the opposite sign.
-
parse
public static TimeDelta parse(String s)
Converts the string representation of a time interval to its `TimeDelta` equivalent.- Parameters:
s
- a string that specifies the time interval to convert.- Returns:
- a time interval that corresponds to `s`.
-
tryParse
public static boolean tryParse(String s, TimeDelta[] result)
Converts the string representation of a time interval to its TimeDelta equivalent and returns a value that indicates whether the conversion succeeded.- Parameters:
s
- a string that specifies the time interval to convert.result
- this array must have at least one element. When this method returns, `result[0]` contains an object that represents the time interval specified by `s`, or a zero-length time interval if the conversion failed.- Returns:
- `true` if s was converted successfully; otherwise, `false`.
-
subtract
public TimeDelta subtract(TimeDelta other)
Returns a new TimeDelta object whose value is a difference between this and `other` instances.- Parameters:
other
- the instance to subtract.- Returns:
- a new object that represents the value of this instance minus value of other instance.
-
equals
public boolean equals(TimeDelta other)
Indicates whether some `other` time span is equal to this one.- Parameters:
other
- time span to compare with.- Returns:
- `true` if intervals equal; `false` otherwise.
-
equals
public boolean equals(Object other)
-
clone
public Object clone()
- Returns:
-
-