Package ucar.nc2.time
Class CalendarPeriod
java.lang.Object
ucar.nc2.time.CalendarPeriod
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 ClassesModifier and TypeClassDescriptionstatic enumFields that can be set on a CalendarPeriod, used to prevent exposure of underlying implementation. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic CalendarPeriod.FieldfromUnitString(String udunit) Convert a period string into a CalendarPeriod.Field.doubleGet the conversion factor of the other CalendarPeriod to this onegetField()intgetOffset(CalendarDate start, CalendarDate end) intgetValue()doubleDeprecated.dont use because these are fixed length and thus approximate.inthashCode()multiply(int value) Multiply the period by an integerstatic CalendarPeriodof(int value, CalendarPeriod.Field field) static CalendarPeriodConvert 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.toString()
-
Field Details
-
Hour
-
-
Method Details
-
fromUnitString
Convert a period string into a CalendarPeriod.Field.- Parameters:
udunit- period string- Returns:
- CalendarPeriod.Field enum
- Throws:
IllegalArgumentException- if not valid format
-
of
-
of
Convert a udunit period string into a CalendarPeriod- Parameters:
udunit- period string : "[val] unit"- Returns:
- CalendarPeriod or null if illegal
-
of
-
multiply
Multiply the period by an integer- Parameters:
value- multiply by this- Returns:
- new period
-
getValue
public int getValue() -
getField
-
subtract
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
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
-
toString
-
equals
-
hashCode
public int hashCode()
-