Class IntervalYearToMonth


  • public final class IntervalYearToMonth
    extends AbstractInterval
    This class implements the Exasol-proprietary data type value INTERVAL YEAR(x) TO MONTH(y). It supports conversions to and from strings and from a number of months.

    In Exasol this data type represents a time difference consisting of the following components:

    • years
    • months

    Since months are the highest resolution, each interval can also be expressed as a total number of months. This is also the recommended way to represent the interval values in other systems which do not natively support this data type.

    • Method Detail

      • toMonths

        public long toMonths()
        Get the interval as the total number of months between two points in time
        Returns:
        total number of months
      • ofMonths

        public static IntervalYearToMonth ofMonths​(long value)
        Create an IntervalDayToSecond from a number of months
        Parameters:
        value - total length of the interval in months
        Returns:
        interval with months resolution
      • parse

        public static IntervalYearToMonth parse​(String text)
        Parse an IntervalDayToSecond from a string

        The accepted format is:

        YYYYYYYYY:MM

        Where

        Y
        years, 1-9 digits, mandatory
        M
        months, 1-2 digits, mandatory
        Parameters:
        text - string representing an interval
        Returns:
        interval with months resolution