Top Description Fields Constructors Methods
com.thoughtworks.xstream.core.util

public Class ThreadSafeSimpleDateFormat

extends Object
Class Inheritance
Imports
java.text.DateFormat, .ParseException, .SimpleDateFormat, java.util.Date, .Locale, .TimeZone

Wrapper around java.text.SimpleDateFormat that can be called by multiple threads concurrently.

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.

Authors
Joe Walnes, Jörg Schaible

Field Summary

Modifier and TypeField and Description
private final String
private final Pool
private final TimeZone

Constructor Summary

AccessConstructor and Description
public
ThreadSafeSimpleDateFormat(String format, TimeZone timeZone, int initialPoolSize, int maxPoolSize, final boolean lenient)

public
ThreadSafeSimpleDateFormat(String format, TimeZone timeZone, final Locale locale, int initialPoolSize, int maxPoolSize, final boolean lenient)

Method Summary

Modifier and TypeMethod and Description
private DateFormat
public String
format(Date date)

public Date
parse(String date)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

formatStringback to summary
private final String formatString
poolback to summary
private final Pool pool
timeZoneback to summary
private final TimeZone timeZone

Constructor Detail

ThreadSafeSimpleDateFormatback to summary
public ThreadSafeSimpleDateFormat(String format, TimeZone timeZone, int initialPoolSize, int maxPoolSize, final boolean lenient)
ThreadSafeSimpleDateFormatback to summary
public ThreadSafeSimpleDateFormat(String format, TimeZone timeZone, final Locale locale, int initialPoolSize, int maxPoolSize, final boolean lenient)

Method Detail

fetchFromPoolback to summary
private DateFormat fetchFromPool()
formatback to summary
public String format(Date date)
parseback to summary
public Date parse(String date) throws ParseException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.