|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DateConverter
A converter for instances representing dates and time zones. Source classes
to support: java.util.Date
, longs as a primitive type or as
java.lang.Long
and
org.norther.tammi.acorn.lang.LongDate
, and strings as
org.norther.tammi.acorn.lang.StringDate
, and time zones as
java.util.TimeZone
.
The styles can be given as a pattern to format or parse a date, time, or a datetime. The default is a datetime. If you want to have dates without time information or vice versa or want to have a different style for the date and time part, you'll need to add a qualifier in front of the style and put the style(s) in parantheses.
After the styles, you can also add a time zone id as defined in
java.util.TimeZone
.
Examples:
The pattern can also be a format understood by the
java.text.SimpleDateFormat
.
A special style "ISO-8601" indicates a date with the format yyyy-MM-dd and a time with the format HH:mm:ss. E.g. the pattern "datetime(ISO-8601)" is equal to the pattern "yyyy-MM-dd HH:mm:ss".
Field Summary | |
---|---|
static String |
DEFAULT_STYLE
Default style. |
static String |
FULL_STYLE
Full style. |
static String |
LONG_STYLE
Long style. |
static String |
MEDIUM_STYLE
Medium style. |
static String |
SHORT_STYLE
Short style. |
Method Summary | |
---|---|
Set<String> |
classNameSet()
Returns a read-only set of class names of defined patterns. |
void |
clearClassSpecificPatterns()
Clears all class specific patterns. |
void |
clearLocalPatternChars()
Clears all locale specific pattern chars. |
String |
getClassSpecificPattern(String className)
Gets the class specific default date pattern. |
DateFormat |
getDateFormat(String className,
String pattern,
Locale... locale)
Gets a date format for the specified class, pattern and locale. |
String |
getDefaultPattern()
Gets the default date pattern. |
String |
getExcelPattern(String className,
String pattern,
Locale... locale)
Gets an Excel format pattern for the specified class, pattern and locale. |
String |
getLocalPatternChars(Locale locale)
Gets the locale specific pattern chars. |
String |
getTimeZoneId()
Gets the default time zone to apply. |
Set<Locale> |
patternLocaleSet()
Returns a read-only set of locales with defined pattern chars. |
void |
removeClassSpecificPattern(String className)
Removes the class specific default date pattern. |
void |
removeLocalPatternChars(Locale locale)
Removes the locale specific pattern chars. |
void |
setClassSpecificPattern(String className,
String pattern)
Sets the class specific default date pattern. |
void |
setDefaultPattern(String pattern)
Sets the default date pattern. |
void |
setLocalPatternChars(Locale locale,
String chars)
Sets the locale specific pattern chars. |
void |
setTimeZoneId(String id)
Sets the default time zone to apply. |
List<String> |
timeZoneIds()
Returns a list of supported time zone ids. |
Date |
toDate(long msecs)
Converts milliseconds to date. |
long |
toTime(Date date)
Converts a date to milliseconds. |
Methods inherited from interface org.norther.tammi.core.converter.ObjectConverter |
---|
getFormatPattern, getInstance, getInstance, getInstance, getLocalizedPattern, getResourceFinderName, setResourceFinderName, toString, toString, toString, toStrings, toStrings, toStrings |
Field Detail |
---|
static final String DEFAULT_STYLE
static final String SHORT_STYLE
static final String MEDIUM_STYLE
static final String LONG_STYLE
static final String FULL_STYLE
Method Detail |
---|
String getDefaultPattern()
void setDefaultPattern(String pattern)
pattern
- the default date pattern.String getClassSpecificPattern(String className)
className
- the class name of the pattern.
void setClassSpecificPattern(String className, String pattern)
className
- the class name of the pattern.pattern
- the class specific default date pattern.void removeClassSpecificPattern(String className)
className
- the class name of the pattern.void clearClassSpecificPatterns()
Set<String> classNameSet()
String getLocalPatternChars(Locale locale)
locale
- the locale.
void setLocalPatternChars(Locale locale, String chars)
locale
- the locale.chars
- the pattern chars.void removeLocalPatternChars(Locale locale)
locale
- the locale.void clearLocalPatternChars()
Set<Locale> patternLocaleSet()
String getTimeZoneId()
void setTimeZoneId(String id)
Note that this method changes the default time zone of the running JVM to the specified value and thus may interfere with other date functionality.
id
- the time zone id.List<String> timeZoneIds()
DateFormat getDateFormat(String className, String pattern, Locale... locale)
className
- the name of the class to format.pattern
- the conversion pattern.locale
- the locale.
DateFormat
String getExcelPattern(String className, String pattern, Locale... locale)
className
- the name of the class to format.pattern
- the conversion pattern.locale
- the locale.
long toTime(Date date)
date
- the date.
Date toDate(long msecs)
msecs
- the millis.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |