public class ThreadSafeSimpleDateFormat
extends java.lang.Object
SimpleDateFormat has a high overhead in creating and is not thread safe. To make best use of resources, the ThreadSafeSimpleDateFormat provides a dynamically sizing pool of instances, each of which will only be called by a single thread at a time.
The pool has a maximum capacity, to limit overhead. If all instances in the pool are in use and another is required, it shall block until one becomes available.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
formatString |
private Pool |
pool |
private java.util.TimeZone |
timeZone |
Constructor and Description |
---|
ThreadSafeSimpleDateFormat(java.lang.String format,
java.util.TimeZone timeZone,
int initialPoolSize,
int maxPoolSize,
boolean lenient) |
ThreadSafeSimpleDateFormat(java.lang.String format,
java.util.TimeZone timeZone,
java.util.Locale locale,
int initialPoolSize,
int maxPoolSize,
boolean lenient) |
Modifier and Type | Method and Description |
---|---|
private java.text.DateFormat |
fetchFromPool() |
java.lang.String |
format(java.util.Date date) |
java.util.Date |
parse(java.lang.String date) |
java.lang.String |
toString() |
private final java.lang.String formatString
private final Pool pool
private final java.util.TimeZone timeZone
public ThreadSafeSimpleDateFormat(java.lang.String format, java.util.TimeZone timeZone, int initialPoolSize, int maxPoolSize, boolean lenient)
public ThreadSafeSimpleDateFormat(java.lang.String format, java.util.TimeZone timeZone, java.util.Locale locale, int initialPoolSize, int maxPoolSize, boolean lenient)
public java.lang.String format(java.util.Date date)
public java.util.Date parse(java.lang.String date) throws java.text.ParseException
java.text.ParseException
private java.text.DateFormat fetchFromPool()
public java.lang.String toString()
toString
in class java.lang.Object