Class DateTickUnit

    • Constructor Detail

      • DateTickUnit

        public DateTickUnit​(DateTickUnitType unitType,
                            int multiple)
        Creates a new date tick unit.
        Parameters:
        unitType - the unit type (null not permitted).
        multiple - the multiple (of the unit type, must be > 0).
      • DateTickUnit

        public DateTickUnit​(DateTickUnitType unitType,
                            int multiple,
                            DateFormat formatter)
        Creates a new date tick unit.
        Parameters:
        unitType - the unit type (null not permitted).
        multiple - the multiple (of the unit type, must be > 0).
        formatter - the date formatter (null not permitted).
      • DateTickUnit

        public DateTickUnit​(DateTickUnitType unitType,
                            int multiple,
                            DateTickUnitType rollUnitType,
                            int rollMultiple,
                            DateFormat formatter)
        Creates a new unit. The rollUnitType and rollCount are intended to roll the date forward when it falls on a "hidden" part of the DateAxis. For example, if the tick size is 1 week (7 days), but Saturday and Sunday are hidden, if the ticks happen to fall on Saturday, none of them will be visible. A sensible rollUnitType/rollCount would be 1 day, so that the date would roll forward to the following Monday, which is visible.
        Parameters:
        unitType - the unit.
        multiple - the multiple.
        rollUnitType - the roll unit.
        rollMultiple - the roll multiple.
        formatter - the date formatter (null not permitted).
    • Method Detail

      • getMultiple

        public int getMultiple()
        Returns the unit multiple.
        Returns:
        The unit multiple (always > 0).
      • getRollMultiple

        public int getRollMultiple()
        Returns the roll unit multiple.
        Returns:
        The roll unit multiple.
      • valueToString

        public String valueToString​(double milliseconds)
        Formats a value.
        Overrides:
        valueToString in class TickUnit
        Parameters:
        milliseconds - date in milliseconds since 01-01-1970.
        Returns:
        The formatted date.
      • dateToString

        public String dateToString​(Date date)
        Formats a date using the tick unit's formatter.
        Parameters:
        date - the date.
        Returns:
        The formatted date.
      • addToDate

        public Date addToDate​(Date base,
                              TimeZone zone)
        Calculates a new date by adding this unit to the base date.
        Parameters:
        base - the base date.
        zone - the time zone for the date calculation.
        Returns:
        A new date one unit after the base date.
      • rollDate

        public Date rollDate​(Date base)
        Rolls the date forward by the amount specified by the roll unit and count.
        Parameters:
        base - the base date.
        Returns:
        The rolled date.
        See Also:
        rollDate(Date, TimeZone)
      • rollDate

        public Date rollDate​(Date base,
                             TimeZone zone)
        Rolls the date forward by the amount specified by the roll unit and count.
        Parameters:
        base - the base date.
        zone - the time zone.
        Returns:
        The rolled date.
      • getCalendarField

        public int getCalendarField()
        Returns a field code that can be used with the Calendar class.
        Returns:
        The field code.
      • equals

        public boolean equals​(Object obj)
        Tests this unit for equality with another object.
        Overrides:
        equals in class TickUnit
        Parameters:
        obj - the object (null permitted).
        Returns:
        true or false.
      • hashCode

        public int hashCode()
        Returns a hash code for this object.
        Overrides:
        hashCode in class TickUnit
        Returns:
        A hash code.
      • toString

        public String toString()
        Returns a string representation of this instance, primarily used for debugging purposes.
        Overrides:
        toString in class Object
        Returns:
        A string representation of this instance.