Package org.alfresco.util
Class CachingDateFormat
java.lang.Object
java.text.Format
java.text.DateFormat
java.text.SimpleDateFormat
org.alfresco.util.CachingDateFormat
- All Implemented Interfaces:
Serializable
,Cloneable
Provides thread safe means of obtaining a cached date formatter.
The cached string-date mappings are stored in a WeakHashMap.
- Author:
- Derek Hulley, Andrea Gazzarini
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final CachingDateFormat.StringAndResolution[]
static final String
static final String
Fields inherited from class java.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
-
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleDateFormat
Returns a thread-safe formatter for the cmis sql datetime format.static SimpleDateFormat
Returns a thread-safe formatter for the generic date/time format.static SimpleDateFormat
getDateFormat
(int length, Locale locale, boolean lenient) static SimpleDateFormat
getDateFormat
(String pattern, boolean lenient) static SimpleDateFormat
static SimpleDateFormat
getDateTimeFormat
(int dateLength, int timeLength, Locale locale, boolean lenient) static SimpleDateFormat
Returns a thread-safe formatter for the Solr ISO 8601 datetime format.static SimpleDateFormat
Returns a thread-safe formatter for the Solr ISO 8601 datetime format (without the msecs part).static SimpleDateFormat
Returns a thread-safe formatter for the generic time format.lenientParse
(String text, int minimumResolution) parse
(String text, ParsePosition pos) Parses and caches date strings.toString()
Methods inherited from class java.text.SimpleDateFormat
applyLocalizedPattern, applyPattern, clone, equals, format, formatToCharacterIterator, get2DigitYearStart, getDateFormatSymbols, hashCode, set2DigitYearStart, setDateFormatSymbols, toLocalizedPattern, toPattern
Methods inherited from class java.text.DateFormat
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
Methods inherited from class java.text.Format
format, parseObject
-
Field Details
-
UTC
- See Also:
-
FORMAT_FULL_GENERIC
- See Also:
-
FORMAT_CMIS_SQL
- See Also:
-
FORMAT_SOLR
- See Also:
-
UTC_WITHOUT_MSECS
- See Also:
-
FORMAT_DATE_GENERIC
- See Also:
-
FORMAT_TIME_GENERIC
- See Also:
-
LENIENT_FORMATS
-
-
Method Details
-
toString
-
getDateFormat
- Parameters:
length
- the type of date format, e.g.DateFormat.LONG
locale
- theLocale
that will be used to determine the date pattern- See Also:
-
getDateTimeFormat
public static SimpleDateFormat getDateTimeFormat(int dateLength, int timeLength, Locale locale, boolean lenient) - Parameters:
dateLength
- the type of date format, e.g.DateFormat.LONG
timeLength
- the type of time format, e.g.DateFormat.LONG
locale
- theLocale
that will be used to determine the date pattern- See Also:
-
getDateFormat
- Parameters:
pattern
- the conversion pattern to uselenient
- true to allow the parser to extract the date in conceivable manner- Returns:
- Returns a conversion-cacheing formatter for the given pattern, but the instance itself is not cached
-
getDateFormat
Returns a thread-safe formatter for the generic date/time format.- Returns:
- a thread-safe formatter for the generic date/time format.
- See Also:
-
getCmisSqlDatetimeFormat
Returns a thread-safe formatter for the cmis sql datetime format.- Returns:
- a thread-safe formatter for the cmis sql datetime format.
- See Also:
-
getSolrDatetimeFormatWithoutMsecs
Returns a thread-safe formatter for the Solr ISO 8601 datetime format (without the msecs part).- Returns:
- Returns a thread-safe formatter for the Solr ISO 8601 datetime format (without the msecs part).
- See Also:
-
getSolrDatetimeFormat
Returns a thread-safe formatter for the Solr ISO 8601 datetime format.- Returns:
- a thread-safe formatter for the Solr ISO 8601 datetime format
- See Also:
-
getDateOnlyFormat
- Returns:
- Returns a thread-safe formatter for the generic date format
- See Also:
-
getTimeOnlyFormat
Returns a thread-safe formatter for the generic time format.- Returns:
- a thread-safe formatter for the generic time format.
- See Also:
-
parse
Parses and caches date strings.- Overrides:
parse
in classSimpleDateFormat
- See Also:
-
lenientParse
public static Pair<Date,Integer> lenientParse(String text, int minimumResolution) throws ParseException - Throws:
ParseException
-
getLenientFormatters
-