Package com.norconex.commons.lang.time
Class RBDurationUnitFormatter
java.lang.Object
com.norconex.commons.lang.time.RBDurationUnitFormatter
- All Implemented Interfaces:
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 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
- Author:
- Pascal Essiembre
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IDurationUnitFormatterstatic final IDurationUnitFormatterstatic final IDurationUnitFormatter -
Constructor Summary
ConstructorsConstructorDescriptionRBDurationUnitFormatter(String baseName) RBDurationUnitFormatter(String baseName, ClassLoader classLoader) -
Method Summary
Modifier and TypeMethodDescriptionbooleanformat(DurationUnit unit, Locale locale, boolean plural) Format a duration unitprotected ResourceBundlegetResourceBundle(Locale locale) inthashCode()toString()
-
Field Details
-
FULL
-
COMPACT
-
ABBREVIATED
-
-
Constructor Details
-
RBDurationUnitFormatter
-
RBDurationUnitFormatter
-
-
Method Details
-
format
Description copied from interface:IDurationUnitFormatterFormat a duration unit- Specified by:
formatin interfaceIDurationUnitFormatter- Parameters:
unit- duration unitlocale- localeplural-trueif plural- Returns:
- formatted unit
-
getClassLoader
-
getBaseName
-
getResourceBundle
-
equals
-
hashCode
public int hashCode() -
toString
-