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 is null
, the default locale will be use.
If the unit is null
, null
will be returned.
Modifier and Type | Field and Description |
---|---|
static IDurationUnitFormatter |
ABBREVIATED |
static IDurationUnitFormatter |
COMPACT |
static IDurationUnitFormatter |
FULL |
Constructor and Description |
---|
RBDurationUnitFormatter(String baseName) |
RBDurationUnitFormatter(String baseName,
ClassLoader classLoader) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
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() |
public static final IDurationUnitFormatter FULL
public static final IDurationUnitFormatter COMPACT
public static final IDurationUnitFormatter ABBREVIATED
public RBDurationUnitFormatter(String baseName)
public RBDurationUnitFormatter(String baseName, ClassLoader classLoader)
public String format(DurationUnit unit, Locale locale, boolean plural)
IDurationUnitFormatter
format
in interface IDurationUnitFormatter
unit
- duration unitlocale
- localeplural
- true
if pluralpublic ClassLoader getClassLoader()
public String getBaseName()
protected ResourceBundle getResourceBundle(Locale locale)
Copyright © 2008–2023 Norconex Inc.. All rights reserved.