Package com.norconex.commons.lang.time
Class RBDurationUnitFormatter
- java.lang.Object
-
- com.norconex.commons.lang.time.RBDurationUnitFormatter
-
- All Implemented Interfaces:
IDurationUnitFormatter
public class RBDurationUnitFormatter extends Object implements IDurationUnitFormatter
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 isnull, the default locale will be use. If the unit isnull,nullwill be returned.- year
- years
- month
- months
- week
- weeks
- day
- days
- hour
- hours
- minute
- minutes
- second
- seconds
- millisecond
- milliseconds
- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
-
Field Summary
Fields Modifier and Type Field Description static IDurationUnitFormatterABBREVIATEDstatic IDurationUnitFormatterCOMPACTstatic IDurationUnitFormatterFULL
-
Constructor Summary
Constructors Constructor Description RBDurationUnitFormatter(String baseName)RBDurationUnitFormatter(String baseName, ClassLoader classLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)Stringformat(DurationUnit unit, Locale locale, boolean plural)Format a duration unitStringgetBaseName()ClassLoadergetClassLoader()protected ResourceBundlegetResourceBundle(Locale locale)inthashCode()StringtoString()
-
-
-
Field Detail
-
FULL
public static final IDurationUnitFormatter FULL
-
COMPACT
public static final IDurationUnitFormatter COMPACT
-
ABBREVIATED
public static final IDurationUnitFormatter ABBREVIATED
-
-
Constructor Detail
-
RBDurationUnitFormatter
public RBDurationUnitFormatter(String baseName)
-
RBDurationUnitFormatter
public RBDurationUnitFormatter(String baseName, ClassLoader classLoader)
-
-
Method Detail
-
format
public String format(DurationUnit unit, Locale locale, boolean plural)
Description copied from interface:IDurationUnitFormatterFormat a duration unit- Specified by:
formatin interfaceIDurationUnitFormatter- Parameters:
unit- duration unitlocale- localeplural-trueif plural- Returns:
- formatted unit
-
getClassLoader
public ClassLoader getClassLoader()
-
getBaseName
public String getBaseName()
-
getResourceBundle
protected ResourceBundle getResourceBundle(Locale locale)
-
-