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 class
CalendarPeriod.Field
Fields that can be set on a CalendarPeriod, used to prevent exposure of underlying implementation.
-
Field Summary
Fields Modifier and Type Field Description static CalendarPeriod
Hour
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object o)
static CalendarPeriod.Field
fromUnitString(String udunit)
Convert a period string into a CalendarPeriod.Field.double
getConvertFactor(CalendarPeriod from)
Get the conversion factor of the other CalendarPeriod to this oneCalendarPeriod.Field
getField()
int
getOffset(CalendarDate start, CalendarDate end)
int
getValue()
double
getValueInMillisecs()
Deprecated.dont use because these are fixed length and thus approximate.int
hashCode()
CalendarPeriod
multiply(int value)
Multiply the period by an integerstatic CalendarPeriod
of(int value, CalendarPeriod.Field field)
static CalendarPeriod
of(String udunit)
Convert a udunit period string into a CalendarPeriodstatic CalendarPeriod
of(TimeDuration td)
int
subtract(CalendarDate start, CalendarDate end)
Subtract two dates, return difference in units of this period.String
toString()
-
-
-
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 to nearest int- 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)
-
-