Package ucar.nc2.units
Class DateType
java.lang.Object
ucar.nc2.units.DateType
Implements 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:
-
- invalid input: '<a href=""https://www.unidata.ucar.edu/projects/THREDDS/tech/catalog/InvCatalogSpec.html#dateType"">THREDDS dateType</a>'
-
Constructor Summary
ConstructorsConstructorDescriptionDateType()no argument constructor for beansConstructor using a java.util.DateConstructor.Constructor.DateType(CalendarDate date) Constructor using a java.util.CalendarDatecopy constructor -
Method Summary
Modifier and TypeMethodDescriptionadd(TimeDuration d) booleanIs this date after the given date.booleanIs this date before the given date.booleanIs this date before the given date.booleanGet this as a CalendarDategetDate()Deprecated.use getCalendarDate()Get the SimpleDateFormat format for parsing the text.getText()Get a text representation.getType()Get the type of Date.inthashCode()booleanisBlank()Was blank text passed to the constructor.booleanDoes this represent the present time.Set the type of Date.Same as DateFormatter.toDateOnlyString()Same as CalendarDateFormatter.toDateTimeStringISOGet ISO formatted stringtoString()String representation
-
Constructor Details
-
DateType
Constructor using a java.util.Date- Parameters:
isPresent- if true, this represents the "present time"date- the given Date
-
DateType
Constructor using a java.util.CalendarDate- Parameters:
date- the given CalendarDate
-
DateType
public DateType()no argument constructor for beans -
DateType
copy constructor- Parameters:
src- copy from here
-
DateType
Constructor.- Parameters:
text- string representationformat- using java.text.SimpleDateFormat, or nulltype- type of date, or null- Throws:
ParseException- if error parsing text
-
DateType
Constructor.- Parameters:
text- string representationformat- using java.text.SimpleDateFormat, or nulltype- type of date, or nullcal2- ucar.nc2.time.Calendar of date, or null- Throws:
ParseException- if error parsing text
-
-
Method Details
-
getDate
Deprecated.use getCalendarDate()Get this as a Date. Does not handle non-standard Calendars.- Returns:
- Date
-
getCalendarDate
Get this as a CalendarDate- Returns:
- CalendarDate
-
isPresent
public boolean isPresent()Does this represent the present time.- Returns:
- true if present time.
-
isBlank
public boolean isBlank()Was blank text passed to the constructor.- Returns:
- true if blank text passed to the constructor.
-
getText
Get a text representation.- Returns:
- text representation
-
getFormat
Get the SimpleDateFormat format for parsing the text.- Returns:
- SimpleDateFormat format, or null
-
getType
Get the type of Date.- Returns:
- type of Date, or null
-
setType
Set the type of Date.- Parameters:
type- type of Date
-
before
Is this date before the given date. if isPresent, always false.- Parameters:
d- test against this date- Returns:
- true if this date before the given date
-
before
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
-
after
Is this date after the given date. if isPresent, always true.- Parameters:
d- test against this date- Returns:
- true if this date after the given date
-
toDateString
Same as DateFormatter.toDateOnlyString()- Returns:
- formatted date
-
toDateTimeString
Same as CalendarDateFormatter.toDateTimeStringISO- Returns:
- formatted date
-
toDateTimeStringISO
Get ISO formatted string- Returns:
- ISO formatted date
-
toString
String representation -
hashCode
public int hashCode() -
equals
-
add
-
add
-
subtract
-
subtract
-