Package ucar.nc2.time
Class CalendarPeriod
- java.lang.Object
-
- ucar.nc2.time.CalendarPeriod
-
@Immutable public class CalendarPeriod extends Object
A CalendarPeriod is a logical duration of time, it requires a Calendar to convert to an actual duration of time. A CalendarField is expressed as {integer x Field}. Design follows joda Period class.- Since:
- 3/30/11
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCalendarPeriod.FieldFields that can be set on a CalendarPeriod, used to prevent exposure of underlying implementation.
-
Field Summary
Fields Modifier and Type Field Description static CalendarPeriodHour
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object o)static CalendarPeriod.FieldfromUnitString(String udunit)Convert a period string into a CalendarPeriod.Field.doublegetConvertFactor(CalendarPeriod from)Get the conversion factor of the other CalendarPeriod to this oneCalendarPeriod.FieldgetField()intgetOffset(CalendarDate start, CalendarDate end)intgetValue()doublegetValueInMillisecs()Deprecated.dont use because these are fixed length and thus approximate.inthashCode()CalendarPeriodmultiply(int value)Multiply the period by an integerstatic CalendarPeriodof(int value, CalendarPeriod.Field field)static CalendarPeriodof(String udunit)Convert a udunit period string into a CalendarPeriodstatic CalendarPeriodof(TimeDuration td)intsubtract(CalendarDate start, CalendarDate end)Subtract two dates, return difference in units of this period.StringtoString()
-
-
-
Field Detail
-
Hour
public static final CalendarPeriod Hour
-
-
Method Detail
-
fromUnitString
public static CalendarPeriod.Field fromUnitString(String udunit)
Convert a period string into a CalendarPeriod.Field.- Parameters:
udunit- period string- Returns:
- CalendarPeriod.Field enum
- Throws:
IllegalArgumentException- if not valid format
-
of
public static CalendarPeriod of(int value, CalendarPeriod.Field field)
-
of
public static CalendarPeriod of(String udunit)
Convert a udunit period string into a CalendarPeriod- Parameters:
udunit- period string : "[val] unit"- Returns:
- CalendarPeriod or null if illegal
-
of
public static CalendarPeriod of(TimeDuration td)
-
multiply
public CalendarPeriod multiply(int value)
Multiply the period by an integer- Parameters:
value- multiply by this- Returns:
- new period
-
getValue
public int getValue()
-
getField
public CalendarPeriod.Field getField()
-
subtract
public int subtract(CalendarDate start, CalendarDate end)
Subtract two dates, return difference in units of this period. If not even, will round down and log a warning- Parameters:
start- start dateend- end date- Returns:
- difference in units of this period
-
getConvertFactor
public double getConvertFactor(CalendarPeriod from)
Get the conversion factor of the other CalendarPeriod to this one- Parameters:
from- convert from this- Returns:
- conversion factor, so that getConvertFactor(from) * from = this
-
getValueInMillisecs
public double getValueInMillisecs()
Deprecated.dont use because these are fixed length and thus approximate.Get the duration in milliseconds -+- Returns:
- the duration in seconds
-
getOffset
public int getOffset(CalendarDate start, CalendarDate end)
-
-