Class Time

java.lang.Object
ch.ivyteam.ivy.scripting.objects.Time
All Implemented Interfaces:
IIvyDataObject, Serializable, Cloneable, Comparable<Time>

public final class Time extends Object implements IIvyDataObject, Comparable<Time>
Time objects represent a day-time in IvyScript. They are immutable.
See Also:
API:
This is a public API.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Time
    An invalid time object.
    static final Time
    An uninitialized time object.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Time object representing the actual time.
    Time(int _hours, int _minutes, int _seconds)
    Creates a new time object.
    Time(String literal)
    Parses a literal and creates a corresponding new time object.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Duration duration)
    Adds some Duration to this Time object.
    Creates a clone of this object.
    int
    compareTo(Time otherTime)
    Compares two Time objects.
    boolean
    equals(Object object)
    Test for equality.
    Formats this Time object with default format.
    The default format is defined in the configuration under Formats > Time > default.
    format(String formatName)
    Formats this Time object with given format.
    int
    Returns the hours of this time object.
    int
    Returns the minutes of this time object.
    int
    Returns the seconds of this time object.
    int
    Same as toNumber().
    minus(Duration duration)
    Subtracts some Duration from this Time object.
    minus(Time time)
    Returns a normalized Duration representing the difference between this Time and the argument.
    int
    Converts the Time object in a number; this number correspond the seconds after 00:00:00.
    Returns this time as a String in the format hh:mm:ss
  • Field Details

    • UNINITIALIZED_TIME

      public static final Time UNINITIALIZED_TIME
      An uninitialized time object.
      API:
      This public API is available in IvyScript and Java. It has the visibility EXPERT.
    • INVALID

      public static final Time INVALID
      An invalid time object. Used by the widget validation
      API:
      This public API is available in IvyScript and Java. It has the visibility EXPERT.
  • 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 IvyScript and Java. It has the visibility NOVICE.
    • Time

      public Time()
      Creates a new Time object representing the actual time.
      API:
      This public API is available in IvyScript and Java. It has the visibility NOVICE.
    • Time

      public Time(String literal)
      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 IvyScript and Java. It has the visibility NOVICE.
  • 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 IvyScript and Java. It has the visibility NOVICE.
    • 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 IvyScript and Java. It has the visibility NOVICE.
    • 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 IvyScript and Java. It has the visibility NOVICE.
    • add

      public Time add(Duration duration)
      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 IvyScript and Java. It has the visibility NOVICE.
    • minus

      public Time minus(Duration duration)
      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 IvyScript and Java. It has the visibility NOVICE.
    • minus

      public Duration minus(Time time)
      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 IvyScript and Java. It has the visibility NOVICE.
    • 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 IvyScript and Java. It has the visibility NOVICE.
    • equals

      public boolean equals(Object object)
      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 IvyScript and Java. It has the visibility EXPERT.
    • hashCode

      public int hashCode()
      Same as toNumber().
      Returns:
      The same as toNumber().
      API:
      This public API is available in IvyScript and Java. It has the visibility EXPERT.
    • format

      public String format()
      Formats this Time object with default format.
      The default format is defined in the configuration under Formats > Time > default.
      Returns:
      formatted string
      API:
      This public API is available in IvyScript and Java. It has the visibility NOVICE.
    • format

      public String format(String formatName)
      Formats this Time object with given format.
      Parameters:
      formatName - Name of a configuration under Formats > Time.
      E.g. "default", "medium", "short" etc.
      Returns:
      formatted string
      API:
      This public API is available in IvyScript and Java. It has the visibility NOVICE.
    • compareTo

      public int compareTo(Time otherTime)
      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 IvyScript and Java. It has the visibility NOVICE.
    • toString

      public String 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 IvyScript and Java. It has the visibility NOVICE.
    • clone

      public Time clone()
      Creates a clone of this object.
      Specified by:
      clone in interface IIvyDataObject
      Returns:
      A shallow clone.
      API:
      This public API is available in IvyScript and Java. It has the visibility EXPERT.