Class DateType


  • @Immutable
    public class DateType
    extends Object
    The thredds "dateType" and "dateTypeFormatted" XML element types. This is mostly a general way to specify dates in a string. It allows a date to mean "present". "Present" always sorts after any date, including dates in the future. It allows an optional attribute called "type" which is an enumeration like "created", "modified", etc taken from Dublin Core vocabulary.

    A DateType can be specified in the following ways:

    1. an xsd:date, with form "CCYY-MM-DD"
    2. an xsd:dateTime with form "CCYY-MM-DDThh:mm:ss"
    3. a valid udunits date string
    4. the string "present"
    See Also:
    THREDDS dateType
    • Constructor Detail

      • DateType

        public DateType​(CalendarDate date)
        Constructor using a CalendarDate
        Parameters:
        date - the given CalendarDate
    • Method Detail

      • present

        public static DateType present()
        Get the DateType representing the present time.
      • parse

        @Nullable
        public static DateType parse​(@Nullable
                                     String text,
                                     @Nullable
                                     String format,
                                     @Nullable
                                     String type,
                                     @Nullable
                                     Calendar calendar)
                              throws ParseException
        Parse text to get a DateType.
        Parameters:
        text - string representation
        format - using java.text.SimpleDateFormat, or null
        type - type of date, or null
        calendar - the calendar, or null for default
        Throws:
        ParseException - or IllegalArgumentException if error parsing text
      • toCalendarDate

        @Nullable
        public CalendarDate toCalendarDate()
        Get the CalendarDate, may be null if isBlank().
      • isPresent

        public boolean isPresent()
        Does this represent the present time?
      • isBlank

        public boolean isBlank()
        Was blank text passed to the constructor?
      • getText

        public String getText()
        Get the original text passed to the constructor.
      • getFormat

        @Nullable
        public String getFormat()
        Get the SimpleDateFormat format for parsing the text, passed into the constructor.
      • getType

        @Nullable
        public String getType()
        Get the type of Date, passed into the constructor.
      • toDateString

        public String toDateString()
        Same as CalendarDateFormatter.toDateString
      • toDateTimeString

        public String toDateTimeString()
        Same as CalendarDateFormatter.toDateTimeStringISO
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • before

        public boolean before​(DateType d)
        Is this date before the given date. if d.isPresent, always true, else if this.isPresent, false.
        Parameters:
        d - test against this date
        Returns:
        true if this date before the given date