## org.jfree.chart.axis
Class DateTickUnit

    java.lang.Object
      org.jfree.chart.axis.TickUnit
          org.jfree.chart.axis.DateTickUnit

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable

    public class DateTickUnit

extends TickUnit
implements java.io.Serializable

A tick unit for use by subclasses of `DateAxis`. Instances of this class are immutable.

See Also:
  Serialized Form

Field Summary
`static int` `DAY` Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
`static int` `HOUR` Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
`static int` `MILLISECOND` Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
`static int` `MINUTE` Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
`static int` `MONTH` Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
`static int` `SECOND` Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
`static int` `YEAR` Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.

Constructor Summary
`DateTickUnit(DateTickUnitType unitType, int multiple)` Creates a new date tick unit.
`DateTickUnit(DateTickUnitType unitType, int multiple, java.text.DateFormat formatter)` Creates a new date tick unit.
`DateTickUnit(DateTickUnitType unitType, int multiple, DateTickUnitType rollUnitType, int rollMultiple, java.text.DateFormat formatter)` Creates a new unit.
`DateTickUnit(int unit, int count)` Deprecated. As of version 1.0.13, use `DateTickUnit( DateTickUnitType, int)`.
`DateTickUnit(int unit, int count, java.text.DateFormat formatter)` Deprecated. As of version 1.0.13, use `DateTickUnit( DateTickUnitType, int, DateFormat)`.
`DateTickUnit(int unit, int count, int rollUnit, int rollCount, java.text.DateFormat formatter)` Deprecated. As of version 1.0.13, use `DateTickUnit( DateTickUnitType, int, DateTickUnitType, int, DateFormat)`.

Method Summary
`java.util.Date` `addToDate(java.util.Date base)` Deprecated. As of JFreeChart 1.0.10, this method is deprecated - you should use `addToDate(Date, TimeZone)` instead.
`java.util.Date` `addToDate(java.util.Date base, java.util.TimeZone zone)` Calculates a new date by adding this unit to the base date.
`java.lang.String` `dateToString(java.util.Date date)` Formats a date using the tick unit's formatter.
`boolean` `equals(java.lang.Object obj)` Tests this unit for equality with another object.
`int` `getCalendarField()` Returns a field code that can be used with the `Calendar` class.
`int` `getCount()` Deprecated. As of version 1.0.13, use `getMultiple()`.
`int` `getMultiple()` Returns the unit multiple.
`int` `getRollCount()` Deprecated. As of version 1.0.13, use the `getRollMultiple()`
`int` `getRollMultiple()` Returns the roll unit multiple.
`int` `getRollUnit()` Deprecated. As of version 1.0.13, use `getRollUnitType()`.
`DateTickUnitType` `getRollUnitType()` Returns the roll unit type.
`int` `getUnit()` Deprecated. As of 1.0.13, use the getUnitType() method.
`DateTickUnitType` `getUnitType()` Returns the unit type.
`int` `hashCode()` Returns a hash code for this object.
`java.util.Date` `rollDate(java.util.Date base)` Rolls the date forward by the amount specified by the roll unit and count.
`java.util.Date` `rollDate(java.util.Date base, java.util.TimeZone zone)` Rolls the date forward by the amount specified by the roll unit and count.
`java.lang.String` `toString()` Returns a string representation of this instance, primarily used for debugging purposes.
`java.lang.String` `valueToString(double milliseconds)` Formats a value.

Methods inherited from class org.jfree.chart.axis.TickUnit
`compareTo, getMinorTickCount, getSize`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### YEAR

    public static final int YEAR

  Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
  A constant for years.

  See Also:
    Constant Field Values

### MONTH

    public static final int MONTH

  Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
  A constant for months.

  See Also:
    Constant Field Values

### DAY

    public static final int DAY

  Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
  A constant for days.

  See Also:
    Constant Field Values

### HOUR

    public static final int HOUR

  Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
  A constant for hours.

  See Also:
    Constant Field Values

### MINUTE

    public static final int MINUTE

  Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
  A constant for minutes.

  See Also:
    Constant Field Values

### SECOND

    public static final int SECOND

  Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
  A constant for seconds.

  See Also:
    Constant Field Values

### MILLISECOND

    public static final int MILLISECOND

  Deprecated. As of version 1.0.13, use `DateTickUnitType` instead.
  A constant for milliseconds.

  See Also:
    Constant Field Values

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).
  Since:
    1.0.13

### DateTickUnit

    public DateTickUnit(DateTickUnitType unitType,
                        int multiple,
                        java.text.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).
  Since:
    1.0.13

### DateTickUnit

    public DateTickUnit(DateTickUnitType unitType,
                        int multiple,
                        DateTickUnitType rollUnitType,
                        int rollMultiple,
                        java.text.DateFormat formatter)

  Creates a new unit.

  Parameters:
    `unitType` - the unit.
    `multiple` - the multiple.
    `rollUnitType` - the roll unit.
    `rollMultiple` - the roll multiple.
    `formatter` - the date formatter (`null` not permitted).
  Since:
    1.0.13

### DateTickUnit

    public DateTickUnit(int unit,
                        int count,
                        java.text.DateFormat formatter)

  Deprecated. As of version 1.0.13, use `DateTickUnit( DateTickUnitType, int, DateFormat)`.

  Creates a new date tick unit. You can specify the units using one of the constants YEAR, MONTH, DAY, HOUR, MINUTE, SECOND or MILLISECOND. In addition, you can specify a unit count, and a date format.

  Parameters:
    `unit` - the unit.
    `count` - the unit count.
    `formatter` - the date formatter (defaults to DateFormat.SHORT).

### DateTickUnit

    public DateTickUnit(int unit,
                        int count)

  Deprecated. As of version 1.0.13, use `DateTickUnit( DateTickUnitType, int)`.

  Creates a new date tick unit. The dates will be formatted using a SHORT format for the default locale.

  Parameters:
    `unit` - the unit.
    `count` - the unit count.

### DateTickUnit

    public DateTickUnit(int unit,
                        int count,
                        int rollUnit,
                        int rollCount,
                        java.text.DateFormat formatter)

  Deprecated. As of version 1.0.13, use `DateTickUnit( DateTickUnitType, int, DateTickUnitType, int, DateFormat)`.

  Creates a new unit.

  Parameters:
    `unit` - the unit.
    `count` - the count.
    `rollUnit` - the roll unit.
    `rollCount` - the roll count.
    `formatter` - the date formatter (defaults to DateFormat.SHORT).

Method Detail

### getUnitType

    public DateTickUnitType getUnitType()

  Returns the unit type.

  Returns:
    The unit type (never `null`).
  Since:
    1.0.13

### getMultiple

    public int getMultiple()

  Returns the unit multiple.

  Returns:
    The unit multiple (always > 0).

### getRollUnitType

    public DateTickUnitType getRollUnitType()

  Returns the roll unit type.

  Returns:
    The roll unit type (never `null`).
  Since:
    1.0.13

### getRollMultiple

    public int getRollMultiple()

  Returns the roll unit multiple.

  Returns:
    The roll unit multiple.
  Since:
    1.0.13

### valueToString

    public java.lang.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 java.lang.String dateToString(java.util.Date date)

  Formats a date using the tick unit's formatter.

  Parameters:
    `date` - the date.
  Returns:
    The formatted date.

### addToDate

    public java.util.Date addToDate(java.util.Date base,
                                    java.util.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.
  Since:
    1.0.6

### rollDate

    public java.util.Date rollDate(java.util.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 java.util.Date rollDate(java.util.Date base,
                                   java.util.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.
  Since:
    1.0.6

### getCalendarField

    public int getCalendarField()

  Returns a field code that can be used with the `Calendar` class.

  Returns:
    The field code.

### equals

    public boolean equals(java.lang.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 java.lang.String toString()

  Returns a string representation of this instance, primarily used for debugging purposes.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    A string representation of this instance.

### getUnit

    public int getUnit()

  Deprecated. As of 1.0.13, use the getUnitType() method.

  Returns the date unit. This will be one of the constants `YEAR`, `MONTH`, `DAY`, `HOUR`, `MINUTE`, `SECOND` or `MILLISECOND`, defined by this class. Note that these constants do NOT correspond to those defined in Java's `Calendar` class.

  Returns:
    The date unit.

### getCount

    public int getCount()

  Deprecated. As of version 1.0.13, use `getMultiple()`.

  Returns the unit count.

  Returns:
    The unit count.

### getRollUnit

    public int getRollUnit()

  Deprecated. As of version 1.0.13, use `getRollUnitType()`.

  Returns the roll unit. This is the amount by which the tick advances if it is "hidden" when displayed on a segmented date axis. Typically the roll will be smaller than the regular tick unit (for example, a 7 day tick unit might use a 1 day roll).

  Returns:
    The roll unit.

### getRollCount

    public int getRollCount()

  Deprecated. As of version 1.0.13, use the `getRollMultiple()`

  Returns the roll count.

  Returns:
    The roll count.

### addToDate

    public java.util.Date addToDate(java.util.Date base)

  Deprecated. As of JFreeChart 1.0.10, this method is deprecated - you should use `addToDate(Date, TimeZone)` instead.

  Calculates a new date by adding this unit to the base date, with calculations performed in the default timezone and locale.

  Parameters:
    `base` - the base date.
  Returns:
    A new date one unit after the base date.
  See Also:
    `addToDate(Date, TimeZone)`