Package ch.ivyteam.ivy.scripting.objects
Class BusinessDuration
- java.lang.Object
-
- ch.ivyteam.ivy.scripting.objects.BusinessDuration
-
- All Implemented Interfaces:
IIvyDataObject
,Serializable
,Cloneable
,Comparable<BusinessDuration>
public class BusinessDuration extends Object implements IIvyDataObject, Comparable<BusinessDuration>
ABusinessDuration
represents an amount of time which is defined as working time. Working times are defined in a business calendar configuration. If a calendar defines working time between 8 AM and 5 PM the business duration of a whole day is 9 hours.- Since:
- 19.12.2011
- See Also:
- Serialized Form
- API:
- This is a public API.
-
-
Field Summary
Fields Modifier and Type Field Description static BusinessDuration
UNINITIALIZED_BUSINESS_DURATION
business duration where all time values are set to zero
-
Constructor Summary
Constructors Constructor Description BusinessDuration(int hours, int minutes, int seconds)
Creates a new not normalizedBusinessDuration
.BusinessDuration(long initialSeconds)
Creates a normalized business duration with a given amount of seconds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BusinessDuration
add(BusinessDuration durationToAdd)
Adds aBusinessDuration
.BusinessDuration
clone()
Creates a clone of this object.int
compareTo(BusinessDuration otherDuration)
Compares two durations lexicographically.BusinessDuration
divide(Number divisor)
Divides theBusinessDuration
by a divisor.boolean
equals(Object otherObj)
Indicates whether aBusinessDuration
object is "equal to" this one.int
getHours()
int
getMinutes()
int
getSeconds()
int
hashCode()
BusinessDuration
multiply(Number factor)
Multiplies theBusinessDuration
with a factor.BusinessDuration
normalize()
Returns a normalized duration.BusinessDuration
subtract(BusinessDuration durationToSubtract)
Subtracts aBusinessDuration
.long
toNumber()
Converts theBusinessDuration
into aNumber
.String
toString()
Returns the duration as String in the ISO-8601 format.
-
-
-
Field Detail
-
UNINITIALIZED_BUSINESS_DURATION
public static final BusinessDuration UNINITIALIZED_BUSINESS_DURATION
business duration where all time values are set to zero- API:
- This public API is available in Java.
-
-
Constructor Detail
-
BusinessDuration
public BusinessDuration(int hours, int minutes, int seconds)
Creates a new not normalizedBusinessDuration
.- Parameters:
hours
-minutes
-seconds
-- See Also:
normalize()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
BusinessDuration
public BusinessDuration(long initialSeconds)
Creates a normalized business duration with a given amount of seconds.- Parameters:
initialSeconds
-- See Also:
normalize()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
-
Method Detail
-
getHours
public int getHours()
- Returns:
- The hour part of the business duration.
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getMinutes
public int getMinutes()
- Returns:
- The minute part of the business duration.
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getSeconds
public int getSeconds()
- Returns:
- The second part of the business duration.
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
add
public BusinessDuration add(BusinessDuration durationToAdd)
Adds aBusinessDuration
.- Parameters:
durationToAdd
- TheBusinessDuration
to add.- Returns:
- A new
BusinessDuration
not normalized instance which is the result of the addition! - See Also:
normalize()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
subtract
public BusinessDuration subtract(BusinessDuration durationToSubtract)
Subtracts aBusinessDuration
.- Parameters:
durationToSubtract
- TheBusinessDuration
to subtract.- Returns:
- A new
BusinessDuration
not normalized instance which is the result of the subtraction. - See Also:
normalize()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
multiply
public BusinessDuration multiply(Number factor)
Multiplies theBusinessDuration
with a factor.- Parameters:
factor
- multiplier- Returns:
- A new
BusinessDuration
not normalized instance which represent the result of this multiplication. - See Also:
normalize()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
divide
public BusinessDuration divide(Number divisor)
Divides theBusinessDuration
by a divisor.- Parameters:
divisor
-- Returns:
- A new
BusinessDuration
normalized instance which represents the result of the division. - See Also:
normalize()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
normalize
public BusinessDuration normalize()
Returns a normalized duration. A Duration is normalized, if seconds, minutes, and hours have the same sign, the absolute values of seconds and minutes are smaller than 60. Hours will never be normalized.
E.g.BusinessDuration(0,2,90).normalize() -> BusinessDuration(0,3,30) BusinessDuration(5,62,61).normalize() -> BusinessDuration(6,3,1) BusinessDuration(28,0,0).normalize() -> BusinessDuration(28,0,0) BusinessDuration(0,4,-90).normalize() -> BusinessDuration(0,2,30)
- Returns:
- A new normalized
BusinessDuration
instance. - API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
equals
public boolean equals(Object otherObj)
Indicates whether aBusinessDuration
object is "equal to" this one.- Returns:
- only
true
for business durations if all fields (hours, minutes, seconds) are equal. E.g.BusinessDuration(0,1,30).equals(BusinessDuration(0,1,30)) -> true BusinessDuration(0,1,30).equals(BusinessDuration(0,0,90)) -> false BusinessDuration(0,1,30).equals(BusinessDuration(0,0,90).normalize()) -> true
- See Also:
Object.equals(java.lang.Object)
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
hashCode
public int hashCode()
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
toString
public String toString()
Returns the duration as String in the ISO-8601 format. E.g.BusinessDuration(1,2,3).toString() -> "1H2M3S" BusinessDuration(0,0,3).toString() -> "3S" BusinessDuration(0,0,0).toString() -> "0S"
UNINITIALIZED_BUSINESS_DURATION
.toString() -> ""- See Also:
Object.toString()
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
toNumber
public long toNumber()
Converts theBusinessDuration
into aNumber
.- Returns:
- Number of all seconds that represent the
BusinessDuration
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
compareTo
public int compareTo(BusinessDuration otherDuration)
Compares two durations lexicographically.- Parameters:
otherDuration
- anotherBusinessDuration
.- Returns:
- 1 if the receiver is smaller than the argument,
0 if the receiver is equal to the argument,
-1 if the receiver is greater than the argument. - API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
clone
public BusinessDuration clone()
Creates a clone of this object.- Specified by:
clone
in interfaceIIvyDataObject
- Returns:
- A shallow clone.
- API:
- This public API is available in IvyScript and Java. It has the visibility EXPERT.
-
-