Class AbstractISODateTime

  • All Implemented Interfaces:
    ISOTemporal, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Date>
    Direct Known Subclasses:
    ISODate, ISODateTime

    public abstract class AbstractISODateTime
    extends Time
    implements ISOTemporal
    The abstract base type for ISO date and date time types. 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

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.StringBuilder append​(java.lang.StringBuilder stringBuilder)
      Appends the canonical lexical representation of this date time to a string builder in the form "YYYY-MM-DDThh:mm:ss[.s+]+/-hh:mm".
      int getDay()  
      ISOTime getISOTime()  
      int getMonth()  
      int getYear()  
      java.util.GregorianCalendar toCalendar()
      Returns a calendar representing this date and time for the default locale.
      java.util.GregorianCalendar toCalendar​(java.util.Locale locale)
      Returns a calendar representing this date and time.
      abstract java.util.Date toDate​(java.util.TimeZone timeZone)
      Returns a date that represents this temporal information in the given time zone.
      abstract ISODate toISODate()
      Returns the date portion of this date and time.
      java.lang.String toString()
      Returns the canonical lexical representation of this date time in the form "YYYY-MM-DDThh:mm:ss[.s+]+/-hh:mm".
      static AbstractISODateTime valueOfLenient​(java.lang.String string)
      Returns an ISO date or date time object holding the value of the specified string.
      static AbstractISODateTime valueOfLiberal​(java.lang.String string)
      Returns an ISO date or date time 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

      • AbstractISODateTime

        protected AbstractISODateTime​(ISOTemporalComponents temporalComponents,
                                      boolean useTime)
        Temporal components constructor.
        Parameters:
        temporalComponents - The components of the time information.
        useTime - true if the time should be used, or false if the given type components should be ignored.
        Throws:
        java.lang.NullPointerException - if the temporal components is null.
    • Method Detail

      • getYear

        public final int getYear()
        Overrides:
        getYear in class java.util.Date
        Returns:
        The year, 0-9999.
      • getMonth

        public final int getMonth()
        Overrides:
        getMonth in class java.util.Date
        Returns:
        The month, 1-12.
      • getDay

        public final int getDay()
        Overrides:
        getDay in class java.util.Date
        Returns:
        The day, 1-31.
      • getISOTime

        public ISOTime getISOTime()
        Returns:
        The time, or null if there is a date with no time (not even midnight)
      • append

        public java.lang.StringBuilder append​(java.lang.StringBuilder stringBuilder)
        Appends the canonical lexical representation of this date time to a string builder in the form "YYYY-MM-DDThh:mm:ss[.s+]+/-hh:mm".
        Specified by:
        append in interface ISOTemporal
        Parameters:
        stringBuilder - The string builder to which the lexical representation will be appended.
        Returns:
        The string builder.
      • valueOfLenient

        public static AbstractISODateTime valueOfLenient​(java.lang.String string)
                                                  throws ArgumentSyntaxException
        Returns an ISO date or date time 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.
        • If time is present, an ISODateTime is returned; otherwise, an ISODate is returned.
        Parameters:
        string - The string to be parsed as a date time.
        Returns:
        An ISO date time 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 AbstractISODateTime valueOfLiberal​(java.lang.String string)
                                                  throws ArgumentSyntaxException
        Returns an ISO date or date time 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.
        • If time is present, an ISODateTime is returned; otherwise, an ISODate is returned.
        • Delimiters are optional.
        Parameters:
        string - The string to be parsed as a date time.
        Returns:
        An ISO date time 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.
      • toCalendar

        public java.util.GregorianCalendar toCalendar()
        Returns a calendar representing this date and time for the default locale. If this object has no time information, midnight UTC will be assumed.
        Returns:
        A calendar representing this date time in the default locale.
        See Also:
        Locale.getDefault()
      • toCalendar

        public java.util.GregorianCalendar toCalendar​(java.util.Locale locale)
        Returns a calendar representing this date and time. If this object has no time information, midnight UTC will be assumed.
        Parameters:
        locale - The locale for which a calendar should be returned.
        Returns:
        A calendar representing this date time in the given locale.
        Throws:
        java.lang.NullPointerException - if the given locale is null.
      • toDate

        public abstract java.util.Date toDate​(java.util.TimeZone timeZone)
        Returns a date that represents this temporal information in the given time zone.
        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.
      • toISODate

        public abstract ISODate toISODate()
        Returns the date portion of this date and time.
        Returns:
        A date and time object with only the date part of this instance.
      • toString

        public java.lang.String toString()
        Returns the canonical lexical representation of this date time in the form "YYYY-MM-DDThh:mm:ss[.s+]+/-hh:mm".
        Specified by:
        toString in interface ISOTemporal
        Overrides:
        toString in class Time
        Returns:
        The canonical lexical representation of this date time.