Package ch.ivyteam.ivy.scripting.objects
Class Time
java.lang.Object
ch.ivyteam.ivy.scripting.objects.Time
- All Implemented Interfaces:
IIvyDataObject
,Serializable
,Cloneable
,Comparable<Time>
Time objects represent a day-time in IvyScript.
They are immutable.
- See Also:
- API:
- This is a public API.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds some Duration to this Time object.clone()
Creates a clone of this object.int
Compares two Time objects.boolean
Test for equality.format()
Formats thisTime
object with default format.
The default format is defined in the configuration underFormats > Time > default
.Formats thisTime
object with given format.int
getHours()
Returns the hours of this time object.int
Returns the minutes of this time object.int
Returns the seconds of this time object.int
hashCode()
Same as toNumber().Subtracts some Duration from this Time object.Returns a normalized Duration representing the difference between this Time and the argument.Returns a java.util.Date object correponding to thisTime
object.int
toNumber()
Converts the Time object in a number; this number correspond the seconds after 00:00:00.toString()
Returns this time as a String in the format hh:mm:ss
-
Field Details
-
UNINITIALIZED_TIME
An uninitialized time object.- API:
- This public API is available in Java.
-
INVALID
An invalid time object. Used by the widget validation- API:
- This public API is available in Java.
-
-
Constructor Details
-
Time
public Time(int _hours, int _minutes, int _seconds) Creates a new time object.- Parameters:
_hours
-_minutes
-_seconds
-- API:
- This public API is available in Java.
-
Time
public Time()Creates a new Time object representing the actual time.- API:
- This public API is available in Java.
-
Time
Parses a literal and creates a corresponding new time object. If the format of the argument is not correct, an uninitialized Object is created.- Parameters:
literal
- A literal to parse in the format hh:mm:ss or hh:mm.- Throws:
IllegalArgumentException
- if the argument has an illegal format.- API:
- This public API is available in Java.
-
Time
Creates a new time object.- Parameters:
_date
- a java time object- API:
- This public API is available in Java.
-
-
Method Details
-
getHours
public int getHours()Returns the hours of this time object.- Returns:
- The hours of this time object.
- API:
- This public API is available in Java.
-
getMinutes
public int getMinutes()Returns the minutes of this time object.- Returns:
- The minutes of this time object.
- API:
- This public API is available in Java.
-
getSeconds
public int getSeconds()Returns the seconds of this time object.- Returns:
- The seconds of this time object.
- API:
- This public API is available in Java.
-
add
Adds some Duration to this Time object.- Parameters:
duration
- A duration.- Returns:
- The time after adding the duration.
- API:
- This public API is available in Java.
-
minus
Subtracts some Duration from this Time object.- Parameters:
duration
- A duration.- Returns:
- The time after adding the duration.
- API:
- This public API is available in Java.
-
minus
Returns a normalized Duration representing the difference between this Time and the argument.- Parameters:
time
-- Returns:
- A normalized Duration
- API:
- This public API is available in Java.
-
toNumber
public int toNumber()Converts the Time object in a number; this number correspond the seconds after 00:00:00.- Returns:
- The number of seconds of this time object.
- API:
- This public API is available in Java.
-
equals
Test for equality.- Parameters:
object
- Another object.- Returns:
- true if the two time objects represents the same time.
- API:
- This public API is available in Java.
-
hashCode
public int hashCode()Same as toNumber().- Returns:
- The same as toNumber().
- API:
- This public API is available in Java.
-
toJavaDate
-
format
Formats thisTime
object with default format.
The default format is defined in the configuration underFormats > Time > default
.- Returns:
- formatted string
- API:
- This public API is available in Java.
-
format
Formats thisTime
object with given format.- Parameters:
formatName
- Name of a configuration underFormats > Time
.
E.g. "default", "medium", "short" etc.- Returns:
- formatted string
- API:
- This public API is available in Java.
-
compareTo
Compares two Time objects.- Parameters:
otherTime
- Some time object.- Returns:
- -1 if the receiver is earlier than the argument, 0 if the receiver and the argument are equal, 1 if the receiver is after the argument.
- See Also:
- API:
- This public API is available in Java.
-
toString
Returns this time as a String in the format hh:mm:ss- Returns:
- this time as a String in the format hh:mm:ss
- API:
- This public API is available in Java.
-
clone
Creates a clone of this object.- Specified by:
clone
in interfaceIIvyDataObject
- Returns:
- A shallow clone.
- API:
- This public API is available in Java.
-