Class NonshareableDateFormatCache

java.lang.Object
org.ka2ddo.util.NonshareableDateFormatCache

public class NonshareableDateFormatCache extends Object
This class provides a cache of SimpleDateFormat objects, such that they don't have to be recreated over and over, yet the users can be reasonably assured that no one else is using the instance they are using.

Note this class does not wrap the SimpleDateFormat objects to ensure they are not being used by threads that didn't actually request them. That can be added if problems still occur.

Author:
Andrew Pavlin, KA2DDO
  • Constructor Details

    • NonshareableDateFormatCache

      public NonshareableDateFormatCache()
  • Method Details

    • get

      public static SimpleDateFormat get(String format)
      Get a SimpleDateFormat object with the specified format, pre-initialized to UTC timezone.
      Parameters:
      format - format String to use
      Returns:
      SimpleDateFormat object with the specified format
    • release

      public static void release(SimpleDateFormat sdf)
      Return a SimpleDateFormat object to the appropriate queue.
      Parameters:
      sdf - SimpleDateFormat object to return
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.