ConcurrentDateFormat (Apache Tomcat 9.0.119 API Documentation)
Description: declaration: package: org.apache.tomcat.util.http, class: ConcurrentDateFormat

# 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 Summary

  Constructors
  Constructor
  Description
  `ConcurrentDateFormat(String format, Locale locale, TimeZone timezone)`
  Creates a thread-safe date formatter with the specified format, locale, and timezone.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `format(Date date)`
  Formats the given date into a string using the configured format pattern.
  `Date`
  `parse(String source)`
  Parses the given string into a date using the configured format pattern.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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