Class Date

    • Constructor Summary

      Constructors 
      Constructor Description
      Date()
      Creates a new Date object representing the actual day.
      Date​(int _year, int _month, int _day)
      Creates a new date object.
      Date​(String literal)
      Parses a Date literal and creates a new corresponding Date object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Date add​(Duration duration)
      Adds a duration to this date.
      Date clone()
      Creates a clone of this object.
      int compareTo​(Date otherDate)
      Compares two dates.
      boolean equals​(Object anotherDate)
      Test two objects for equality.
      String format()
      Formats this Date with the default format.
      The default format is defined in the configuration under Formats > Date > default.
      String format​(String formatName)
      Formats this Date with the given format config.
      int getDay()
      Returns the day of the date.
      int getDayOfWeek()
      Returns the day of the week for this date.
      Duration getDurationFromNow()
      Calculates the duration from the current date to actual date instance.
      int getMonth()
      Returns the month of the date.
      int getYear()
      Returns the year of the date.
      int hashCode()
      A hash code.
      Duration minus​(Date date)
      Returns a normalized Duration representing the difference between this Date and the argument.
      Date minus​(Duration duration)
      Subtracts a duration to this date.
      long toNumber()
      Converts this date to a number; this is the number of second of this date after 1970-01-01 00:00:00.
      String toString()
      Returns the date as String in the ISO-8601 format (yyyy-mm-dd).
    • Field Detail

      • UNINITIALIZED_DATE

        public static final Date UNINITIALIZED_DATE
        An uninitialized date object.
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • INVALID

        public static final Date INVALID
        An invalid date object. Used by the widget validation
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
    • Constructor Detail

      • Date

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

        public Date​(int _year,
                    int _month,
                    int _day)
        Creates a new date object.
        Parameters:
        _year - The year of the date.
        _month - The month of the date. 1=January, 2=February, .. 11=November, 12=December
        _day - The day of the date. 1..28, 29, 30, 31 depending on month
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • Date

        public Date​(String literal)
        Parses a Date literal and creates a new corresponding Date object. If the format of the argument is not correct, an uninitialized Object is created.
        Parameters:
        literal - A date literal in the format yyyy-mm-dd or dd.mm.yyyy.
        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 Detail

      • getYear

        public int getYear()
        Returns the year of the date.
        Returns:
        The year of the date.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getMonth

        public int getMonth()
        Returns the month of the date.
        Returns:
        The month of the date. 1=January, 2=February .. 11=November, 12=December
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getDay

        public int getDay()
        Returns the day of the date.
        Returns:
        The day of the date. 1..28, 29, 30, 31 depending on month
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getDayOfWeek

        public int getDayOfWeek()
        Returns the day of the week for this date.
        Returns:
        The day of the week for this date. 1=Sunday, 2=Monday, .. 6=Friday, 7=Saturday
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • add

        public Date add​(Duration duration)
        Adds a duration to this date.
        Parameters:
        duration - A duration.
        Returns:
        A new date objact translated by the duration.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • minus

        public Date minus​(Duration duration)
        Subtracts a duration to this date.
        Parameters:
        duration - A duration.
        Returns:
        A new date objact translated by the duration.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • minus

        public Duration minus​(Date date)
        Returns a normalized Duration representing the difference between this Date and the argument. The result Duration has no year or month part.
        Parameters:
        date -
        Returns:
        a normalized Duration.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getDurationFromNow

        public Duration getDurationFromNow()
        Calculates the duration from the current date to actual date instance.
        Returns:
        Duration from the current date to actual date instance.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • toNumber

        public long toNumber()
        Converts this date to a number; this is the number of second of this date after 1970-01-01 00:00:00.
        Returns:
        Number of seconds after 1970-01-01 00:00:00.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • compareTo

        public int compareTo​(Date otherDate)
        Compares two dates.
        Parameters:
        otherDate - Some date.
        Returns:
        -1 if the receiver is before the argument, 0 if the receiver is equal to the argument 1 if the receiver is after the argument.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • toString

        public String toString()
        Returns the date as String in the ISO-8601 format (yyyy-mm-dd).
        Returns:
        The date as String in the ISO-8601 format (yyyy-mm-dd).
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • format

        public String format()
        Formats this Date with the default format.
        The default format is defined in the configuration under Formats > Date > 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 Date with the given format config.
        Parameters:
        formatName - Name of a configuration under Formats > Date.
        E.g. "default", "medium", "short" etc.
        Returns:
        formatted String
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • equals

        public boolean equals​(Object anotherDate)
        Test two objects for equality.
        Parameters:
        anotherDate - Some object.
        Returns:
        true if the receiver is equal to the argument.
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • hashCode

        public int hashCode()
        A hash code.
        Returns:
        A hash code.
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • clone

        public Date 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.