public class ThreadLocalDateFormat extends DateFormat
ThreadLocalDateFormat simplifies handling of SimpleDateFormat
in concurrent, multi-threaded environments. This class serves as a thin wrapper
that delegates formatting and parsing tasks to thread-local instances.DateFormat.Field| Modifier and Type | Field and Description |
|---|---|
static String |
ISO_FORMAT_MASK
Default format template used when default constructor is invoked.
|
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| Constructor and Description |
|---|
ThreadLocalDateFormat()
Creates a new instance using
ISO_FORMAT_MASK formatting
template. |
ThreadLocalDateFormat(String template)
Creates a new instance using the provided formatting template for the underlying
SimpleDateFormat. |
ThreadLocalDateFormat(String template,
Locale locale)
Creates a new instance using the provided formatting template and
non-default
Locale for the underlying
SimpleDateFormat. |
| Modifier and Type | Method and Description |
|---|---|
ThreadLocalDateFormat |
clone() |
StringBuffer |
format(Date date,
StringBuffer toAppendTo,
FieldPosition pos) |
Date |
parse(String source,
ParsePosition pos) |
equals, format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, hashCode, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZoneformat, formatToCharacterIterator, parseObjectpublic static final String ISO_FORMAT_MASK
public ThreadLocalDateFormat()
ISO_FORMAT_MASK formatting
template.public ThreadLocalDateFormat(String template)
SimpleDateFormat.template - format templatepublic ThreadLocalDateFormat(String template, Locale locale)
Locale for the underlying
SimpleDateFormat.template - format templatelocale - locale to be usedpublic StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
format in class DateFormatpublic Date parse(String source, ParsePosition pos)
parse in class DateFormatpublic ThreadLocalDateFormat clone()
clone in class DateFormatCopyright © 2014 Boleslav Bobcik - Auderis. All rights reserved.