public final class LocaleConverter extends AbstractConverter<Locale>
Converter
implementation for the
java.util.Locale
type.Modifier and Type | Field and Description |
---|---|
static LocaleConverter |
DEFAULT
LocaleConverter single instance. |
Modifier and Type | Method and Description |
---|---|
protected <T> Locale |
doDecode(String value,
ValidationContext<T> context)
Converts string representation of locale into
java.util.Locale object. |
protected <T> String |
doEncode(Locale value,
ValidationContext<T> context)
Converts
java.util.Locale object into string representation. |
static String |
getDisplayName(Locale value,
Locale locale)
Returns localized name for the specified locale.
|
Class<Locale> |
getType()
Returns
java.util.Locale type. |
static Locale |
parseLocale(String value)
Parses the specified default string representation of locale.
|
decode, encode
appendMessageArguments, getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendMessageArguments, getMessageTemplate
public static final LocaleConverter DEFAULT
LocaleConverter
single instance.public Class<Locale> getType()
java.util.Locale
type.java.util.Locale
type.protected <T> Locale doDecode(String value, ValidationContext<T> context)
java.util.Locale
object.
This method doesn't parse localized string representations of locale.
doDecode
in class AbstractConverter<Locale>
T
- The type of validated entity.value
- String representation of locale.context
- Validation context.java.util.Locale
object.MalformedValueException
- if the specified string could not be
parsed as locale.protected <T> String doEncode(Locale value, ValidationContext<T> context)
java.util.Locale
object into string representation.doEncode
in class AbstractConverter<Locale>
T
- The type of validated entity.value
- java.util.Locale
object to be encoded.context
- Validation context.public static Locale parseLocale(String value)
value
- Default string representation of locale.java.util.Locale
object or null
if the specified value cannot be parsed.Copyright © 2011–2020 FoxLabs. All rights reserved.