Package com.restfb.util
Class CachedDateFormatStrategy
- java.lang.Object
-
- com.restfb.util.CachedDateFormatStrategy
-
- All Implemented Interfaces:
DateFormatStrategy
public class CachedDateFormatStrategy extends Object implements DateFormatStrategy
a DateFormat strategy that returns a cached SimpleDateFormat instance. For every format string an instance of the SimpleDateFormat is saved on a per thread base, so the SimpleDateFormat instance is reused and you get an major speedup. Attention: to prevent a possible memory leak while using this strategy you have to clean up the inner ThreadLocal with theclearThreadLocal
method.- Since:
- 1.7.0
-
-
Constructor Summary
Constructors Constructor Description CachedDateFormatStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearThreadLocal()
DateFormat
formatFor(String format)
fetch the DateFormat instance that is used to parse a date in the DateUtils
-
-
-
Constructor Detail
-
CachedDateFormatStrategy
public CachedDateFormatStrategy()
-
-
Method Detail
-
formatFor
public DateFormat formatFor(String format)
Description copied from interface:DateFormatStrategy
fetch the DateFormat instance that is used to parse a date in the DateUtils- Specified by:
formatFor
in interfaceDateFormatStrategy
- Parameters:
format
- the format pattern as string- Returns:
- a DateFormat instance
-
clearThreadLocal
public void clearThreadLocal()
-
-