public final class TimeZoneConverter extends AbstractConverter<TimeZone>
Converter
implementation for the
java.util.TimeZone
type.Modifier and Type | Field and Description |
---|---|
static TimeZoneConverter |
DEFAULT
TimeZoneConverter single instance. |
Modifier and Type | Method and Description |
---|---|
protected <T> TimeZone |
doDecode(String value,
ValidationContext<T> context)
Converts string representation of time zone into
java.util.TimeZone object. |
protected <T> String |
doEncode(TimeZone value,
ValidationContext<T> context)
Converts
java.util.TimeZone object into string
representation. |
static String |
getDisplayName(TimeZone value,
Locale locale)
Returns localized name for the specified time zone.
|
static String |
getID(TimeZone value)
Returns ID for the specified time zone.
|
Class<TimeZone> |
getType()
Returns
java.util.TimeZone type. |
static TimeZone |
parseTimeZone(String value)
Returns time zone for the specified ID.
|
static String |
toGMTString(int offset)
Returns GMT string of the format
GMT+HH:MM for the
specified time zone raw offset. |
decode, encode
appendMessageArguments, getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendMessageArguments, getMessageTemplate
public static final TimeZoneConverter DEFAULT
TimeZoneConverter
single instance.public Class<TimeZone> getType()
java.util.TimeZone
type.java.util.TimeZone
type.protected <T> TimeZone doDecode(String value, ValidationContext<T> context)
java.util.TimeZone
object. The value specified should be
either a time zone ID, an abbreviation or a GMT string or an offset in
hours.
This method doesn't parse localized string representations of time zone.
doDecode
in class AbstractConverter<TimeZone>
T
- The type of validated entity.value
- String representation of time zone.context
- Validation context.java.util.TimeZone
object.MalformedValueException
- if the specified string could not be
parsed as time zone.protected <T> String doEncode(TimeZone value, ValidationContext<T> context)
java.util.TimeZone
object into string
representation.doEncode
in class AbstractConverter<TimeZone>
T
- The type of validated entity.value
- java.util.TimeZone
object to be encoded.context
- Validation context.public static String toGMTString(int offset)
GMT+HH:MM
for the
specified time zone raw offset.offset
- Time zone raw offset.public static TimeZone parseTimeZone(String value)
value
- Time zone ID.null
if ID is not
valid time zone ID.public static String getID(TimeZone value)
value
- Time zone which ID to be returned.public static String getDisplayName(TimeZone value, Locale locale)
(GMT+HH:MM) TIME-ZONE-NAME
for the
specified locale.value
- Time zone which name to be returned.locale
- Desired locale.Copyright © 2011–2020 FoxLabs. All rights reserved.