Class ThreadSafeDateFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class ThreadSafeDateFormat
    extends java.text.DateFormat
    Thread-safe version of java.text.DateFormat. You can declare it as a static final variable:
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.text.DateFormat

        java.text.DateFormat.Field
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String dateFormat  
      private java.lang.ThreadLocal<java.lang.ref.SoftReference<java.text.SimpleDateFormat>> formatCache  
      private static long serialVersionUID  
      • Fields inherited from class java.text.DateFormat

        AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
    • Constructor Summary

      Constructors 
      Constructor Description
      ThreadSafeDateFormat​(java.lang.String sDateFormat)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.StringBuffer format​(java.util.Date date, java.lang.StringBuffer toAppendTo, java.text.FieldPosition fieldPosition)  
      private java.text.DateFormat getDateFormat()  
      java.util.Date parse​(java.lang.String source, java.text.ParsePosition pos)  
      • Methods inherited from class java.text.DateFormat

        clone, equals, format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, hashCode, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
      • Methods inherited from class java.text.Format

        format, formatToCharacterIterator, parseObject
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • dateFormat

        private final java.lang.String dateFormat
      • formatCache

        private final java.lang.ThreadLocal<java.lang.ref.SoftReference<java.text.SimpleDateFormat>> formatCache
    • Constructor Detail

      • ThreadSafeDateFormat

        public ThreadSafeDateFormat​(java.lang.String sDateFormat)
    • Method Detail

      • getDateFormat

        private java.text.DateFormat getDateFormat()
      • format

        public java.lang.StringBuffer format​(java.util.Date date,
                                             java.lang.StringBuffer toAppendTo,
                                             java.text.FieldPosition fieldPosition)
        Specified by:
        format in class java.text.DateFormat
      • parse

        public java.util.Date parse​(java.lang.String source,
                                    java.text.ParsePosition pos)
        Specified by:
        parse in class java.text.DateFormat