Class ISODate

  • All Implemented Interfaces:
    ISOTemporal, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>

    public class ISODate
    extends AbstractISODateTime
    The class representing an ISO date type. If there is no explicit UTC offset (i.e. this is a floating value), the time is stored internally in terms of UTC.
    Author:
    Garret Wilson
    See Also:
    Serialized Form
    • Nested Class Summary

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ISODate​(int year, int month, int day)
      Date components constructor.
        ISODate​(long time)
      Millisecond time constructor in terms of UTC.
        ISODate​(long time, java.util.TimeZone timeZone)
      Millisecond time constructor in terms of the given time zone.
      protected ISODate​(ISOTemporalComponents temporalComponents)
      Temporal component constructor.
        ISODate​(java.util.Date date)
      Date constructor in terms of UTC.
        ISODate​(java.util.Date date, java.util.TimeZone timeZone)
      Date constructor in terms the given time zone.
        ISODate​(java.util.GregorianCalendar calendar)
      Calendar constructor in terms of UTC.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.GregorianCalendar toCalendar​(java.util.TimeZone timeZone)
      Returns a calendar that represents this temporal information in the given time zone.
      java.util.Date toDate​(java.util.TimeZone timeZone)
      Returns a date that represents this temporal information in the given time zone.
      ISODate toISODate()
      Returns the date portion of this date and time.
      static ISODate valueOf​(java.lang.String string)
      Returns an ISO date object holding the value of the specified string.
      static ISODate valueOfLenient​(java.lang.String string)
      Returns an ISO date object holding the value of the specified string.
      static ISODate valueOfLiberal​(java.lang.String string)
      Returns an ISO date object holding the value of the specified string.
      • Methods inherited from class java.util.Date

        after, before, clone, compareTo, equals, from, getDate, getHours, getMinutes, getSeconds, getTime, getTimezoneOffset, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toInstant, toLocaleString, UTC
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ISODate

        protected ISODate​(ISOTemporalComponents temporalComponents)
        Temporal component constructor.
        Parameters:
        temporalComponents - The temporal components from which to construct the class.
        Throws:
        java.lang.NullPointerException - if the given temporal components is null.
      • ISODate

        public ISODate​(int year,
                       int month,
                       int day)
        Date components constructor. The underlying Date will be constructed in terms of UTC.
        Parameters:
        year - The year, 0-9999.
        month - The month, 1-12.
        day - The day, 1-31.
        Throws:
        java.lang.IllegalArgumentException - if one of the given arguments is outside the allowed range.
      • ISODate

        public ISODate​(java.util.GregorianCalendar calendar)
        Calendar constructor in terms of UTC. Any time-related information of the given calendar will be lost; only the date will be kept, in terms of the calendar's time zone.
        Parameters:
        calendar - The calendar representing the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC; and a time zone.
        Throws:
        java.lang.NullPointerException - if the given calendar is null.
      • ISODate

        public ISODate​(java.util.Date date)
        Date constructor in terms of UTC. Any time-related information of the given date will be lost; only the date will be kept, in terms of midnight UTC.
        Parameters:
        date - The date representing the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
        Throws:
        java.lang.NullPointerException - if the given date is null.
      • ISODate

        public ISODate​(java.util.Date date,
                       java.util.TimeZone timeZone)
        Date constructor in terms the given time zone. Any time-related information of the given date will be lost; only the date will be kept, in terms of the given time zone.
        Parameters:
        date - The date representing the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
        timeZone - The time zone in which the time should be interpreted.
        Throws:
        java.lang.NullPointerException - if the given date and/or time zone is null.
        java.lang.IllegalArgumentException - if a time zone was provided with an unsupported offset for the given time.
      • ISODate

        public ISODate​(long time)
        Millisecond time constructor in terms of UTC. Any time-related information of the given time will be lost; only the date will be kept, in terms of midnight UTC.
        Parameters:
        time - The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
      • ISODate

        public ISODate​(long time,
                       java.util.TimeZone timeZone)
        Millisecond time constructor in terms of the given time zone. Any time-related information of the given time will be lost; only the date will be kept, in terms of the given time zone.
        Parameters:
        time - The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
        timeZone - The time zone in which the time should be interpreted.
        Throws:
        java.lang.NullPointerException - if the given time zone is null.
        java.lang.IllegalArgumentException - if a time zone was provided with an unsupported offset for the given time.
    • Method Detail

      • toDate

        public java.util.Date toDate​(java.util.TimeZone timeZone)
        Returns a date that represents this temporal information in the given time zone.
        Specified by:
        toDate in class AbstractISODateTime
        Parameters:
        timeZone - The time zone which the date should represent.
        Returns:
        The date this object represents in relation to the given time zone.
        Throws:
        java.lang.NullPointerException - if the given time zone is null.
        See Also:
        toCalendar(TimeZone)
      • toCalendar

        public java.util.GregorianCalendar toCalendar​(java.util.TimeZone timeZone)
        Returns a calendar that represents this temporal information in the given time zone.
        Parameters:
        timeZone - The time zone which the date should represent.
        Returns:
        The calendar this object represents in relation to the given time zone.
        Throws:
        java.lang.NullPointerException - if the given time zone is null.
      • toISODate

        public ISODate toISODate()
        Returns the date portion of this date and time.
        Specified by:
        toISODate in class AbstractISODateTime
        Returns:
        A date and time object with only the date part of this instance.
      • valueOf

        public static ISODate valueOf​(java.lang.String string)
                               throws ArgumentSyntaxException
        Returns an ISO date object holding the value of the specified string.
        Parameters:
        string - The string to be parsed as a date.
        Returns:
        An ISO date object represented by the string.
        Throws:
        java.lang.NullPointerException - if the given string is null
        ArgumentSyntaxException - if the given string does not have the correct syntax.
      • valueOfLenient

        public static ISODate valueOfLenient​(java.lang.String string)
                                      throws ArgumentSyntaxException
        Returns an ISO date object holding the value of the specified string.

        Lenient parsing makes the following allowances:

        • Seconds are considered optional.
        • Whitespace before and after the date/time is allowed.
        • The looser RFC 3339 Internet timestamp format is allowed, allowing the UTC designator, 90, for example.
        Parameters:
        string - The string to be parsed as a date.
        Returns:
        An ISO date object represented by the string.
        Throws:
        java.lang.NullPointerException - if the given string is null
        ArgumentSyntaxException - if the given string does not have the correct syntax.
      • valueOfLiberal

        public static ISODate valueOfLiberal​(java.lang.String string)
                                      throws ArgumentSyntaxException
        Returns an ISO date object holding the value of the specified string.

        Liberal parsing makes the following allowances:

        • Seconds are considered optional.
        • Whitespace before and after the date/time is allowed.
        • The looser RFC 3339 Internet timestamp format is allowed, allowing the UTC designator, 90, for example.
        • Delimiters are optional.
        Parameters:
        string - The string to be parsed as a date.
        Returns:
        An ISO date object represented by the string.
        Throws:
        java.lang.NullPointerException - if the given string is null
        ArgumentSyntaxException - if the given string does not have the correct syntax.