Package com.norconex.commons.lang.time
Class RbDurationUnitFormatter
java.lang.Object
com.norconex.commons.lang.time.RbDurationUnitFormatter
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic final DurationUnitFormatterstatic final DurationUnitFormatterstatic final DurationUnitFormatter -
Constructor Summary
ConstructorsConstructorDescriptionRbDurationUnitFormatter(String baseName) RbDurationUnitFormatter(String baseName, ClassLoader classLoader) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanformat(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:DurationUnitFormatterFormat a duration unit- Specified by:
formatin interfaceDurationUnitFormatter- Parameters:
unit- duration unitlocale- localeplural-trueif plural- Returns:
- formatted unit
-
getResourceBundle
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode() -
getBaseName
-
getClassLoader
-