Package com.norconex.commons.lang.time

# Class RbDurationUnitFormatter

java.lang.Object
com.norconex.commons.lang.time.RbDurationUnitFormatter

All Implemented Interfaces:
  `DurationUnitFormatter`

public class RbDurationUnitFormatter extends Object implements DurationUnitFormatter

Use localized properties files (`ResourceBundle`) to get the string representation of duration unit. Each properties file is expected to have the following keys, their plural versions being optional (if a plural unit is spelled the same as singular).

If a key is not found, the `toString()` version of the unit will be returned. If locale is `null`, the default locale will be use. If the unit is `null`, `null` will be returned.

- year
- years
- month
- months
- week
- weeks
- day
- days
- hour
- hours
- minute
- minutes
- second
- seconds
- millisecond
- milliseconds

Since:
  2.0.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final DurationUnitFormatter`
  `ABBREVIATED`
  `static final DurationUnitFormatter`
  `COMPACT`
  `static final DurationUnitFormatter`
  `FULL`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RbDurationUnitFormatter(String baseName)`
  `RbDurationUnitFormatter(String baseName, ClassLoader classLoader)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected boolean`
  `canEqual(Object other)`
  `boolean`
  `equals(Object o)`
  `String`
  `format(DurationUnit unit, Locale locale, boolean plural)`
  Format a duration unit
  `String`
  `getBaseName()`
  `ClassLoader`
  `getClassLoader()`
  `protected ResourceBundle`
  `getResourceBundle(Locale locale)`
  `int`
  `hashCode()`
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### FULL

    public static final DurationUnitFormatter FULL

  - ### COMPACT

    public static final DurationUnitFormatter COMPACT

  - ### ABBREVIATED

    public static final DurationUnitFormatter ABBREVIATED

- ## Constructor Details

  - ### RbDurationUnitFormatter

    public RbDurationUnitFormatter(String baseName)

  - ### RbDurationUnitFormatter

    public RbDurationUnitFormatter(String baseName, ClassLoader classLoader)

- ## Method Details

  - ### format

    public String format(DurationUnit unit, Locale locale, boolean plural)
    Description copied from interface: `DurationUnitFormatter`
    Format a duration unit
    Specified by:
      `format` in interface `DurationUnitFormatter`
    Parameters:
      `unit` - duration unit
      `locale` - locale
      `plural` - `true` if plural
    Returns:
      formatted unit

  - ### getResourceBundle

    protected ResourceBundle getResourceBundle(Locale locale)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### canEqual

    protected boolean canEqual(Object other)

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### getBaseName

    public String getBaseName()

  - ### getClassLoader

    public ClassLoader getClassLoader()