Class ConcurrentDateFormat

java.lang.Object
org.apache.tomcat.util.http.ConcurrentDateFormat

public class ConcurrentDateFormat extends Object
A thread safe wrapper around SimpleDateFormat that does not make use of ThreadLocal and - broadly - only creates enough SimpleDateFormat objects to satisfy the concurrency requirements.
  • Constructor Details

    • ConcurrentDateFormat

      public ConcurrentDateFormat(String format, Locale locale, TimeZone timezone)
      Creates a thread-safe date formatter with the specified format, locale, and timezone.
      Parameters:
      format - the date format pattern
      locale - the locale to use for formatting
      timezone - the time zone to use for formatting
  • Method Details

    • format

      public String format(Date date)
      Formats the given date into a string using the configured format pattern.
      Parameters:
      date - the date to format
      Returns:
      the formatted date string
    • parse

      public Date parse(String source) throws ParseException
      Parses the given string into a date using the configured format pattern.
      Parameters:
      source - the string to parse
      Returns:
      the parsed date
      Throws:
      ParseException - if the string cannot be parsed