Package ucar.nc2.time
Class CalendarDateUnit
- java.lang.Object
-
- ucar.nc2.time.CalendarDateUnit
-
@Immutable public class CalendarDateUnit extends Object
A Calendar Date Unit: "unit since date"UNIT since [-]Y[Y[Y[Y]]]-MM-DD[(T| )hh[:mm[:ss[.sss*]]][ [+|-]hh[[:]mm]]] UNIT = "msecs" | "msec" | "seconds" | "second" | "secs" | "sec" | "s" | "minutes" | "minute" | "mins" | "min" | "hours" | "hour" | "hrs" | "hr" | "h" | "days" | "day" | "d""months since base_date by calendar field" "years since base_date by calendar field" bob simon's proposal: "calendar_month since base_date" "calendar_year since base_date" * only integer values are allowed (?) jon blowers comment: In your view would the solution to add "by calendar field" to the existing udunits string be acceptable? It’s backward-compatible with the current interpretation and adds clarification for the cases in which we *do* want to do calendar-field arithmetic (instead of adding fixed intervals). There’s an alternative proposition, in which the new units of calendar_month and calendar_year are added, with the same semantic effect. (However, personally I like the "by calendar field" solution since it allows other fields to vary between calendars, e.g. because of leap-seconds.)- Since:
- 3/18/11
-
-
Field Summary
Fields Modifier and Type Field Description static StringudunitPatternStringstatic CalendarDateUnitunixDateUnit
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)CalendarDategetBaseCalendarDate()CalendargetCalendar()CalendarPeriod.FieldgetCalendarField()CalendarPeriodgetCalendarPeriod()StringgetUdUnit()inthashCode()booleanisCalendarField()CalendarDatemakeCalendarDate(double value)CalendarDatemakeCalendarDate(int value)doublemakeOffsetFromRefDate(CalendarDate date)static CalendarDateUnitof(String calendarName, String udunitString)Create a CalendarDateUnit from a calendar name and a udunit string = "unit since calendarDate"static CalendarDateUnitof(Calendar calt, CalendarPeriod.Field periodField, CalendarDate baseDate)Create a CalendarDateUnit from a calendar, a CalendarPeriod.Field, and a base dateStringtoString()static CalendarDateUnitwithCalendar(Calendar calt, String udunitString)Create a CalendarDateUnit from a calendar and a udunit string = "unit since calendarDate"
-
-
-
Field Detail
-
unixDateUnit
public static final CalendarDateUnit unixDateUnit
-
udunitPatternString
public static final String udunitPatternString
- See Also:
- Constant Field Values
-
-
Method Detail
-
of
public static CalendarDateUnit of(String calendarName, String udunitString)
Create a CalendarDateUnit from a calendar name and a udunit string = "unit since calendarDate"- Parameters:
calendarName- must match a calendar enum, or one of its aliases, see ucar.nc2.time.Calendar.get()udunitString- "unit since calendarDate"- Returns:
- CalendarDateUnit
- Throws:
IllegalArgumentException- if udunitString is not paresable
-
withCalendar
public static CalendarDateUnit withCalendar(Calendar calt, String udunitString)
Create a CalendarDateUnit from a calendar and a udunit string = "unit since calendarDate"- Parameters:
calt- use this Calendar, or null for default calendarudunitString- "unit since calendarDate"- Returns:
- CalendarDateUnit
- Throws:
IllegalArgumentException- if udunitString is not paresable
-
of
public static CalendarDateUnit of(Calendar calt, CalendarPeriod.Field periodField, CalendarDate baseDate)
Create a CalendarDateUnit from a calendar, a CalendarPeriod.Field, and a base date- Parameters:
calt- use this Calendar, or null for default calendarperiodField- a CalendarPeriod.Field like Hour or secondbaseDate- "since baseDate"- Returns:
- CalendarDateUnit
-
makeOffsetFromRefDate
public double makeOffsetFromRefDate(CalendarDate date)
-
makeCalendarDate
public CalendarDate makeCalendarDate(double value)
-
makeCalendarDate
public CalendarDate makeCalendarDate(int value)
-
getUdUnit
public String getUdUnit()
-
getBaseCalendarDate
public CalendarDate getBaseCalendarDate()
-
getCalendarPeriod
public CalendarPeriod getCalendarPeriod()
-
getCalendarField
public CalendarPeriod.Field getCalendarField()
-
getCalendar
public Calendar getCalendar()
-
isCalendarField
public boolean isCalendarField()
-
-