Class DateUtils.DateFormatHolder

  • Enclosing class:
    DateUtils

    static final class DateUtils.DateFormatHolder
    extends java.lang.Object
    A factory for SimpleDateFormats. The instances are stored in a threadlocal way because SimpleDateFormat is not threadsafe as noted in its javadoc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.ThreadLocal<java.lang.ref.SoftReference<java.util.Map<java.lang.String,​java.text.SimpleDateFormat>>> THREADLOCAL_FORMATS  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void clearThreadLocal()  
      static java.text.SimpleDateFormat formatFor​(java.lang.String pattern)
      creates a SimpleDateFormat for the requested format string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • THREADLOCAL_FORMATS

        private static final java.lang.ThreadLocal<java.lang.ref.SoftReference<java.util.Map<java.lang.String,​java.text.SimpleDateFormat>>> THREADLOCAL_FORMATS
    • Constructor Detail

      • DateFormatHolder

        DateFormatHolder()
    • Method Detail

      • formatFor

        public static java.text.SimpleDateFormat formatFor​(java.lang.String pattern)
        creates a SimpleDateFormat for the requested format string.
        Parameters:
        pattern - a non-null format String according to SimpleDateFormat. The format is not checked against null since all paths go through DateUtils.
        Returns:
        the requested format. This simple dateformat should not be used to apply to a different pattern.
      • clearThreadLocal

        public static void clearThreadLocal()