public class DateConverter extends AbstractConverter
String
and vice versa.
The following types are handled for conversions :
Conversions between these representations are handled, and also from String (Default patterns is ISO: yyy-MM-dd) and Long.Constructor and Description |
---|
DateConverter() |
Modifier and Type | Method and Description |
---|---|
static void |
addGlobalPattern(String pattern)
Global patterns are used by all formatters for parsing if their preferred pattern does not match.
|
void |
addSpecificPattern(String pattern)
Specific patterns are used by this formatters for parsing if their preferred pattern does not match.
|
protected String |
dateToString(Date d)
Converts a Date object to a String, using the preferred parsing pattern.
|
protected DateFormat |
getDefaultFormat(boolean noDefault)
Creates a
DateFormat from the instance parameter:
If pattern is configured, uses this parameter. |
protected DateFormat |
getFormat(String pattern)
Creates a
DateFormat from the provided pattern and configured timezone. |
protected static LinkedHashSet<String> |
getGlobalpatterns() |
Locale |
getLocale() |
String |
getPreferredPattern()
Retrieved preferred formatting pattern.
|
protected LinkedHashSet<String> |
getSpecificpatterns() |
TimeZone |
getTimeZone() |
Class<?>[] |
getTypes()
Returns types handled by the converter.
|
protected String |
internalConvertToString(Object o)
Returns the default "toString" result on provided Object.
|
protected <T> T |
internalConvertToType(Class<T> type,
Object o)
Handles conversion to an handled type.
|
static void |
removeGlobalPattern(String pattern)
Global patterns are used by all formatters for parsing if their preferred pattern does not match.
|
void |
removeSpecificPattern(String pattern)
Specific patterns are used by this formatters for parsing if their preferred pattern does not match.
|
void |
setLocale(Locale locale) |
void |
setPreferredPattern(String preferredPattern)
Sets preferred formatting pattern.
|
void |
setTimeZone(TimeZone timeZone) |
convertArrayToString, convertArrayToType, convertCollectionToString, convertCollectionToType, convertionException, convertionException, convertToString, convertToType, stringConversion, toString, typeConversion
protected String internalConvertToString(Object o) throws UtilsException
AbstractConverter
internalConvertToString
in class AbstractConverter
UtilsException
protected <T> T internalConvertToType(Class<T> type, Object o) throws UtilsException
AbstractConverter
internalConvertToType
in class AbstractConverter
UtilsException
public Class<?>[] getTypes()
IConverter
protected String dateToString(Date d) throws UtilsException
UtilsException
protected DateFormat getDefaultFormat(boolean noDefault)
DateFormat
from the instance parameter:
noDefault
- If true, null will be returned but not system default.protected DateFormat getFormat(String pattern)
DateFormat
from the provided pattern and configured timezone.public TimeZone getTimeZone()
public void setTimeZone(TimeZone timeZone)
public Locale getLocale()
public void setLocale(Locale locale)
public String getPreferredPattern()
public void setPreferredPattern(String preferredPattern)
public static void addGlobalPattern(String pattern)
public static void removeGlobalPattern(String pattern)
protected static LinkedHashSet<String> getGlobalpatterns()
public void addSpecificPattern(String pattern)
public void removeSpecificPattern(String pattern)
protected LinkedHashSet<String> getSpecificpatterns()