Package org.apache.tomcat.util.http
Class ConcurrentDateFormat
- java.lang.Object
-
- org.apache.tomcat.util.http.ConcurrentDateFormat
-
public class ConcurrentDateFormat extends java.lang.ObjectA thread safe wrapper aroundSimpleDateFormatthat does not make use of ThreadLocal and - broadly - only creates enough SimpleDateFormat objects to satisfy the concurrency requirements.
-
-
Constructor Summary
Constructors Constructor Description ConcurrentDateFormat(java.lang.String format, java.util.Locale locale, java.util.TimeZone timezone)Creates a thread-safe date formatter with the specified format, locale, and timezone.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringformat(java.util.Date date)Formats the given date into a string using the configured format pattern.java.util.Dateparse(java.lang.String source)Parses the given string into a date using the configured format pattern.
-
-
-
Constructor Detail
-
ConcurrentDateFormat
public ConcurrentDateFormat(java.lang.String format, java.util.Locale locale, java.util.TimeZone timezone)Creates a thread-safe date formatter with the specified format, locale, and timezone.- Parameters:
format- the date format patternlocale- the locale to use for formattingtimezone- the time zone to use for formatting
-
-
Method Detail
-
format
public java.lang.String format(java.util.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 java.util.Date parse(java.lang.String source) throws java.text.ParseExceptionParses the given string into a date using the configured format pattern.- Parameters:
source- the string to parse- Returns:
- the parsed date
- Throws:
java.text.ParseException- if the string cannot be parsed
-
-