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
,null
will 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 IDurationUnitFormatter
ABBREVIATED
static IDurationUnitFormatter
COMPACT
static IDurationUnitFormatter
FULL
-
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 boolean
equals(Object other)
String
format(DurationUnit unit, Locale locale, boolean plural)
Format a duration unitString
getBaseName()
ClassLoader
getClassLoader()
protected ResourceBundle
getResourceBundle(Locale locale)
int
hashCode()
String
toString()
-
-
-
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:IDurationUnitFormatter
Format a duration unit- Specified by:
format
in interfaceIDurationUnitFormatter
- Parameters:
unit
- duration unitlocale
- localeplural
-true
if plural- Returns:
- formatted unit
-
getClassLoader
public ClassLoader getClassLoader()
-
getBaseName
public String getBaseName()
-
getResourceBundle
protected ResourceBundle getResourceBundle(Locale locale)
-
-