Package org.apache.catalina.util
Class Strftime
java.lang.Object
org.apache.catalina.util.Strftime
Converts dates to strings using the same format specifiers as strftime Notes:
- This does not mimic strftime perfectly. Certain strftime commands, are not supported, and will convert as if they were literals.
- Certain complicated commands, like those dealing with the week of the year probably don't have exactly the same behavior as strftime.
- These limitations are due to use SimpleDateTime. If the conversion was done manually, all these limitations could be eliminated.
- The interface looks like a subset of DateFormat. Maybe someday someone will make this class extend DateFormat.
- Author:
- Bip Thelin, Dan Sandberg
-
Field Summary
Modifier and TypeFieldDescriptionprotected final SimpleDateFormat
protected static final Properties
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
convertDateFormat
(String pattern) Search the provided pattern and get the C standard Date/Time formatting rules and convert them to the Java equivalent.Format the date according to the strftime-style string given in the constructor.Get the timezone used for formatting conversionsprotected String
void
setTimeZone
(TimeZone timeZone) Change the timezone used to format datesprotected boolean
translateCommand
(StringBuilder buf, String pattern, int index, boolean oldInside) Try to get the Java Date/Time formatting associated with the C standard provided.
-
Field Details
-
translate
-
simpleDateFormat
-
-
Constructor Details
-
Strftime
Create an instance of this date formatting class- Parameters:
origFormat
- the strftime-style formatting stringlocale
- the locale to use for locale-specific conversions
-
-
Method Details
-
format
Format the date according to the strftime-style string given in the constructor.- Parameters:
date
- the date to format- Returns:
- the formatted date
-
getTimeZone
Get the timezone used for formatting conversions- Returns:
- the timezone
-
setTimeZone
Change the timezone used to format dates- Parameters:
timeZone
- The new time zone- See Also:
-
convertDateFormat
Search the provided pattern and get the C standard Date/Time formatting rules and convert them to the Java equivalent.- Parameters:
pattern
- The pattern to search- Returns:
- The modified pattern
-
quote
-
translateCommand
Try to get the Java Date/Time formatting associated with the C standard provided.- Parameters:
buf
- The bufferpattern
- The date/time patternindex
- The char indexoldInside
- Flag value- Returns:
- True if new is inside buffer
-