Package thredds.client.catalog
Class DateType
- java.lang.Object
-
- thredds.client.catalog.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:- an xsd:date, with form "CCYY-MM-DD"
- an xsd:dateTime with form "CCYY-MM-DDThh:mm:ss"
- a valid udunits date string
- the string "present"
- See Also:
- THREDDS dateType
-
-
Constructor Summary
Constructors Constructor Description DateType(CalendarDate date)
Constructor using a CalendarDate
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DateType
add(TimeDuration d)
DateType
add(TimeUnit d)
boolean
before(DateType d)
Is this date before the given date.boolean
equals(Object o)
String
getFormat()
Get the SimpleDateFormat format for parsing the text, passed into the constructor.String
getText()
Get the original text passed to the constructor.String
getType()
Get the type of Date, passed into the constructor.int
hashCode()
boolean
isBlank()
Was blank text passed to the constructor?boolean
isPresent()
Does this represent the present time?static DateType
parse(String text)
Parse text to get a DateType.static DateType
parse(String text, String format, String type, Calendar calendar)
Parse text to get a DateType.static DateType
present()
Get the DateType representing the present time.DateType
subtract(TimeDuration d)
DateType
subtract(TimeUnit d)
CalendarDate
toCalendarDate()
Get the CalendarDate, may be null if isBlank().String
toDateString()
Same as CalendarDateFormatter.toDateStringString
toDateTimeString()
Same as CalendarDateFormatter.toDateTimeStringISOString
toString()
-
-
-
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
public static DateType parse(String text) throws ParseException
Parse text to get a DateType.- Parameters:
text
- string representation- Throws:
ParseException
-
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 representationformat
- using java.text.SimpleDateFormat, or nulltype
- type of date, or nullcalendar
- 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
-
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
-
add
public DateType add(TimeDuration d)
-
subtract
public DateType subtract(TimeDuration d)
-
-