Class DateFormatSupplier
- java.lang.Object
-
- java.lang.ThreadLocal<DateFormat>
-
- org.apache.accumulo.core.util.format.DateFormatSupplier
-
- All Implemented Interfaces:
Supplier<DateFormat>
public abstract class DateFormatSupplier extends ThreadLocal<DateFormat> implements Supplier<DateFormat>
DateFormatSupplier is aThreadLocal<DateFormat>
that will set the correct TimeZone when the object is retrieved byget()
. This exists as a way to get around thread safety issues inDateFormat
. This class also contains helper methods that create some useful DateFormatSuppliers. Instances of DateFormatSuppliers can be shared, but note that a DateFormat generated from it will be shared by all classes within a Thread. In general, the state of a retrieved DateFormat should not be changed, unless it makes sense to only perform a state change within that Thread.
-
-
Field Summary
Fields Modifier and Type Field Description static String
HUMAN_READABLE_FORMAT
-
Constructor Summary
Constructors Constructor Description DateFormatSupplier()
DateFormatSupplier(TimeZone timeZone)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DateFormatSupplier
createDefaultFormatSupplier()
Create a Supplier forFormatterConfig.DefaultDateFormat
sstatic DateFormatSupplier
createSimpleFormatSupplier(String dateFormat)
Create a generator for SimpleDateFormats accepting a dateFormatstatic DateFormatSupplier
createSimpleFormatSupplier(String dateFormat, TimeZone timeZone)
Create a generator for SimpleDateFormats accepting a dateFormatDateFormat
get()
Always sets the TimeZone, which is a fast operationTimeZone
getTimeZone()
void
setTimeZone(TimeZone timeZone)
-
Methods inherited from class java.lang.ThreadLocal
initialValue, remove, set, withInitial
-
-
-
-
Field Detail
-
HUMAN_READABLE_FORMAT
public static final String HUMAN_READABLE_FORMAT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DateFormatSupplier
public DateFormatSupplier()
-
DateFormatSupplier
public DateFormatSupplier(TimeZone timeZone)
-
-
Method Detail
-
getTimeZone
public TimeZone getTimeZone()
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
-
get
public DateFormat get()
Always sets the TimeZone, which is a fast operation- Specified by:
get
in interfaceSupplier<DateFormat>
- Overrides:
get
in classThreadLocal<DateFormat>
-
createDefaultFormatSupplier
public static DateFormatSupplier createDefaultFormatSupplier()
Create a Supplier forFormatterConfig.DefaultDateFormat
s
-
createSimpleFormatSupplier
public static DateFormatSupplier createSimpleFormatSupplier(String dateFormat)
Create a generator for SimpleDateFormats accepting a dateFormat
-
createSimpleFormatSupplier
public static DateFormatSupplier createSimpleFormatSupplier(String dateFormat, TimeZone timeZone)
Create a generator for SimpleDateFormats accepting a dateFormat
-
-