Class 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 Details

    • MAX_CACHE_SIZE

      public static final int MAX_CACHE_SIZE
      The default number of items to keep in the cache
      See Also:
  • Method Details

    • 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 be null nor 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 be null nor 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 be null nor 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 be null nor empty.
      eResolverStyle - The resolver style to be used. May not be null.
      Returns:
      The compiled DateTimeFormatter and never null.
      Throws:
      IllegalArgumentException - If the pattern is invalid