Package com.helger.commons.datetime
Class DateTimeFormatterCache
- java.lang.Object
-
- com.helger.commons.cache.MappedCache<KEYTYPE,KEYTYPE,VALUETYPE>
-
- com.helger.commons.cache.Cache<DateTimeFormatterPattern,DateTimeFormatter>
-
- com.helger.commons.datetime.DateTimeFormatterCache
-
- All Implemented Interfaces:
ICache<DateTimeFormatterPattern,DateTimeFormatter>,IMutableCache<DateTimeFormatterPattern,DateTimeFormatter>,IHasSize,IHasName
@ThreadSafe @Singleton public final class DateTimeFormatterCache extends Cache<DateTimeFormatterPattern,DateTimeFormatter>
This class provides a cache forDateTimeFormatterinstances. It caches up to a limited number of compiledDateTimeFormatterobjects.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_CACHE_SIZEThe default number of items to keep in the cache-
Fields inherited from class com.helger.commons.cache.Cache
DEFAULT_ALLOW_NULL_VALUES
-
Fields inherited from class com.helger.commons.cache.MappedCache
m_aRWLock, NO_MAX_SIZE, STATISTICS_PREFIX
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DateTimeFormattergetDateTimeFormatter(String sPattern, ResolverStyle eResolverStyle)Get the cached DateTimeFormatter using the provided resolver style.static DateTimeFormattergetDateTimeFormatterLenient(String sPattern)Get the cached DateTimeFormatter using LENIENT resolving.static DateTimeFormattergetDateTimeFormatterSmart(String sPattern)Get the cached DateTimeFormatter using SMART resolving.static DateTimeFormattergetDateTimeFormatterStrict(String sPattern)Get the cached DateTimeFormatter using STRICT resolving.static DateTimeFormatterCachegetInstance()static booleanisInstantiated()-
Methods inherited from class com.helger.commons.cache.MappedCache
clearCache, createCache, getCacheKeyProvider, getFromCache, getFromCacheNoStats, getFromCacheNoStatsNotLocked, getMaxSize, getName, getValueProvider, hasMaxSize, isAllowNullValues, isEmpty, isInCache, isNotEmpty, putInCache, putInCacheNotLocked, removeFromCache, size, toString
-
-
-
-
Field Detail
-
MAX_CACHE_SIZE
public static final int MAX_CACHE_SIZE
The default number of items to keep in the cache- See Also:
- Constant Field Values
-
-
Method Detail
-
isInstantiated
public static boolean isInstantiated()
-
getInstance
@Nonnull public static DateTimeFormatterCache getInstance()
-
getDateTimeFormatterStrict
@Nonnull public static DateTimeFormatter getDateTimeFormatterStrict(@Nonnull @Nonempty String sPattern)
Get the cached DateTimeFormatter using STRICT resolving.- Parameters:
sPattern- The pattern to retrieve. May neither benullnor empty.- Returns:
- The compiled DateTimeFormatter and never
null. - Throws:
IllegalArgumentException- If the pattern is invalid
-
getDateTimeFormatterSmart
@Nonnull public static DateTimeFormatter getDateTimeFormatterSmart(@Nonnull @Nonempty String sPattern)
Get the cached DateTimeFormatter using SMART resolving.- Parameters:
sPattern- The pattern to retrieve. May neither benullnor empty.- Returns:
- The compiled DateTimeFormatter and never
null. - Throws:
IllegalArgumentException- If the pattern is invalid
-
getDateTimeFormatterLenient
@Nonnull public static DateTimeFormatter getDateTimeFormatterLenient(@Nonnull @Nonempty String sPattern)
Get the cached DateTimeFormatter using LENIENT resolving.- Parameters:
sPattern- The pattern to retrieve. May neither benullnor empty.- Returns:
- The compiled DateTimeFormatter and never
null. - Throws:
IllegalArgumentException- If the pattern is invalid
-
getDateTimeFormatter
@Nonnull public static DateTimeFormatter getDateTimeFormatter(@Nonnull @Nonempty String sPattern, @Nonnull ResolverStyle eResolverStyle)
Get the cached DateTimeFormatter using the provided resolver style.- Parameters:
sPattern- The pattern to retrieve. May neither benullnor empty.eResolverStyle- The resolver style to be used. May not benull.- Returns:
- The compiled DateTimeFormatter and never
null. - Throws:
IllegalArgumentException- If the pattern is invalid
-
-