Package org.apache.catalina.util
Class Strftime
- java.lang.Object
-
- org.apache.catalina.util.Strftime
-
public class Strftime extends Object
Converts dates to strings using the same format specifiers as strftime Note: 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.- Version:
- $Revision: 1.3 $, $Date: 2005/12/08 01:28:20 $
- Author:
- Bip Thelin, Dan Sandberg
-
-
Field Summary
Fields Modifier and Type Field Description protected SimpleDateFormatsimpleDateFormatprotected static Propertiestranslate
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringconvertDateFormat(String pattern)Search the provided pattern and get the C standard Date/Time formatting rules and convert them to the Java equivalent.Stringformat(Date date)Format the date according to the strftime-style string given in the constructor.TimeZonegetTimeZone()Get the timezone used for formatting conversionsprotected Stringquote(String str, boolean insideQuotes)voidsetTimeZone(TimeZone timeZone)Change the timezone used to format datesprotected booleantranslateCommand(StringBuilder buf, String pattern, int index, boolean oldInside)try to get the Java Date/Time formating associated with the C standard provided
-
-
-
Field Detail
-
translate
protected static final Properties translate
-
simpleDateFormat
protected SimpleDateFormat simpleDateFormat
-
-
Constructor Detail
-
Strftime
public Strftime(String origFormat)
Create an instance of this date formatting class- See Also:
Strftime( String, Locale )
-
-
Method Detail
-
format
public String format(Date date)
Format the date according to the strftime-style string given in the constructor.- Parameters:
date- the date to format- Returns:
- the formatted date
-
getTimeZone
public TimeZone getTimeZone()
Get the timezone used for formatting conversions- Returns:
- the timezone
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
Change the timezone used to format dates
-
convertDateFormat
protected String convertDateFormat(String pattern)
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
-
translateCommand
protected boolean translateCommand(StringBuilder buf, String pattern, int index, boolean oldInside)
try to get the Java Date/Time formating associated with the C standard provided- Parameters:
buf- translated StringBuilderpattern- command to translateindex- first character indexoldInside- whether to close the quotes if inside quote- Returns:
- The Java formatting rule to use
-
-