Package com.helixframework.time.format
Class ThreadSafeSimpleDateFormat
java.lang.Object
java.text.Format
java.text.DateFormat
com.helixframework.time.format.ThreadSafeSimpleDateFormat
- All Implemented Interfaces:
Serializable,Cloneable
This class is a thread-safe implementation of the DateFormat class that wraps around a SimpleDateFormat object.
It ensures that each thread gets its own instance of SimpleDateFormat and that these instances are properly
initialized, avoiding any clash or race conditions. It provides methods for formatting and parsing dates and
also includes methods for setting timezone, calendar, number format, lenient flag, date format symbols, and
2-digit year start.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field -
Field Summary
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 -
Constructor Summary
ConstructorsConstructorDescriptionThreadSafeSimpleDateFormat(String format) This class is a thread-safe implementation of the DateFormat class that wraps around a SimpleDateFormat object. -
Method Summary
Modifier and TypeMethodDescriptionformat(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) parse(String source, ParsePosition pos) voidset2DigitYearStart(Date date) Sets the 2-digit year start for this ThreadSafeSimpleDateFormat.voidsetCalendar(Calendar cal) voidsetDateFormatSymbols(DateFormatSymbols symbols) Sets the DateFormatSymbols used by the formatter.voidsetLenient(boolean lenient) voidsetNumberFormat(NumberFormat format) voidsetTimeZone(TimeZone tz) Methods inherited from class java.text.DateFormat
clone, equals, format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, hashCode, isLenient, parse, parseObjectMethods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
-
Constructor Details
-
ThreadSafeSimpleDateFormat
This class is a thread-safe implementation of the DateFormat class that wraps around a SimpleDateFormat object. It ensures that each thread gets its own instance of SimpleDateFormat and that these instances are properly initialized, avoiding any clash or race conditions. It provides methods for formatting and parsing dates and also includes methods for setting timezone, calendar, number format, lenient flag, date format symbols, and 2-digit year start.
-
-
Method Details
-
format
- Specified by:
formatin classDateFormat
-
parse
- Specified by:
parsein classDateFormat
-
setTimeZone
- Overrides:
setTimeZonein classDateFormat
-
getTimeZone
- Overrides:
getTimeZonein classDateFormat
-
setCalendar
- Overrides:
setCalendarin classDateFormat
-
setNumberFormat
- Overrides:
setNumberFormatin classDateFormat
-
setLenient
public void setLenient(boolean lenient) - Overrides:
setLenientin classDateFormat
-
setDateFormatSymbols
Sets the DateFormatSymbols used by the formatter.- Parameters:
symbols- the new DateFormatSymbols to be used
-
set2DigitYearStart
Sets the 2-digit year start for this ThreadSafeSimpleDateFormat.- Parameters:
date- the date to set as the 2-digit year start
-