Class 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 CalendarPeriod is expressed as {integer x Field}.
    • Method Detail

      • fromUnitString

        @Nullable
        public static CalendarPeriod.Field fromUnitString​(String udunit)
        Convert a udunit period string into a CalendarPeriod.Field.
        Parameters:
        udunit - period string
        Returns:
        CalendarPeriod.Field enum or null if not valid format
      • of

        @Nullable
        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 format or unknown unit
      • withValue

        public CalendarPeriod withValue​(int value)
        Create a new CalendarPeriod with same Field and different value.
      • getValue

        public int getValue()
        The number of Fields, eg 30 minutes.
      • getChronoUnit

        public ChronoUnit getChronoUnit()
        The java.time.ChronoUnit
      • isDefaultCalendarField

        public boolean isDefaultCalendarField()
        Whether a field has CALENDAR on by default. True for Month and Year.
      • getConvertFactor

        public double getConvertFactor​(CalendarPeriod from)
        Get the conversion factor of the other CalendarPeriod to this one. Cant be used for Month or Year.
        Parameters:
        from - convert from this
        Returns:
        conversion factor, so that getConvertFactor(from) * from = this
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object