public class DateUnit
extends java.lang.Object
This is a wrapper around ucar.units package. It tracks the value, the base time unit, and the date origin seperately.
Constructor and Description |
---|
DateUnit(double value,
java.lang.String timeUnitString,
java.util.Date since)
Constructor that takes a value, timeUnitString, and a Date since
|
DateUnit(java.lang.String text)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static DateUnit |
factory(java.lang.String text) |
java.util.Date |
getDate()
Get the equivalent java.util.Date.
|
java.util.Date |
getDateOrigin()
Get the origin Date.
|
static java.util.Date |
getStandardDate(java.lang.String text)
Create a java.util.Date from this udunits String.
|
static java.util.Date |
getStandardOrISO(java.lang.String text)
Create a java.util.Date from a udunit or ISO String.
|
TimeUnit |
getTimeUnit()
For udunit dates, get the time unit.
|
java.lang.String |
getTimeUnitString()
For udunit dates, get the time unit only, as a String, eg "secs" or "days"
|
java.lang.String |
getUnitsString()
The udunits string, but no value, ie its a base unit.
|
static DateUnit |
getUnixDateUnit() |
static void |
main(java.lang.String[] args) |
CalendarDate |
makeCalendarDate(double val)
Get the equivalent CalendarDate.
|
java.util.Date |
makeDate(double val)
Create a Date from this base unit and the given value.
|
java.lang.String |
makeStandardDateString(double value)
Make a standard GMT string representation from this unit and given value.
|
double |
makeValue(java.util.Date date)
Create the equivalent value from this base unit and the given Date.
|
static CalendarDate |
parseCalendarDate(java.lang.String text) |
java.lang.String |
toString() |
public DateUnit(java.lang.String text) throws java.lang.Exception
text
- udunits String, eg 3 secs since 1991-01-01T03:12java.lang.Exception
- if malformed String.public DateUnit(double value, java.lang.String timeUnitString, java.util.Date since) throws java.lang.Exception
value
- number of time unitstimeUnitString
- eg "secs"since
- date since, eg "secs since 1970-01-01T00:00:00Z"java.lang.Exception
- if not valid time unit.public static java.util.Date getStandardDate(java.lang.String text)
text
- a udunit string.
[number] (units) since [-]Y[Y[Y[Y]]]-MM-DD[(T| )hh[:mm[:ss[.sss*]]][ [+|-]hh[[:]mm]]]
public static java.util.Date getStandardOrISO(java.lang.String text)
text
- a udunit or ISO string.getStandardDate(java.lang.String)
,
DateFormatter.getISODate(java.lang.String)
public static CalendarDate parseCalendarDate(java.lang.String text)
public static DateUnit getUnixDateUnit()
public static DateUnit factory(java.lang.String text)
public java.util.Date getDateOrigin()
public java.lang.String getTimeUnitString()
public TimeUnit getTimeUnit()
public java.util.Date getDate()
public CalendarDate makeCalendarDate(double val)
public java.util.Date makeDate(double val)
val
- value in the units of this base unit, eg sec since base datepublic double makeValue(java.util.Date date)
date
- to convert.public java.lang.String makeStandardDateString(double value)
value
- of time in these units.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getUnitsString()
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception