Package com.helger.commons.datetime
Class DateTimeFormatterCache
java.lang.Object
com.helger.commons.cache.MappedCache<DateTimeFormatterPattern,DateTimeFormatterPattern,DateTimeFormatter>
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 for
DateTimeFormatter instances. It
caches up to a limited number of compiled DateTimeFormatter objects.- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default number of items to keep in the cacheFields inherited from class com.helger.commons.cache.Cache
DEFAULT_ALLOW_NULL_VALUESFields inherited from class com.helger.commons.cache.MappedCache
m_aRWLock, NO_MAX_SIZE, STATISTICS_PREFIX -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 DateTimeFormatterCachestatic booleanMethods 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 Details
-
MAX_CACHE_SIZE
public static final int MAX_CACHE_SIZEThe default number of items to keep in the cache- See Also:
-
-
Method Details
-
isInstantiated
public static boolean isInstantiated() -
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
-