org.apache.catalina.util
Class Strftime
java.lang.Object
org.apache.catalina.util.Strftime
public class Strftime
extends java.lang.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:
- Bip Thelin
- Dan Sandberg
Strftime(String origFormat) - Create an instance of this date formatting class
|
Strftime(String origFormat, Locale locale) - Create an instance of this date formatting class
|
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.
|
String | format(Date date) - Format the date according to the strftime-style string given in the constructor.
|
TimeZone | getTimeZone() - Get the timezone used for formatting conversions
|
protected String | quote(String str, boolean insideQuotes)
|
void | setTimeZone(TimeZone timeZone) - Change the timezone used to format dates
|
protected boolean | translateCommand(StringBuffer buf, String pattern, int index, boolean oldInside) - try to get the Java Date/Time formating associated with
the C standard provided
|
simpleDateFormat
protected SimpleDateFormat simpleDateFormat
translate
protected static Properties translate
Strftime
public Strftime(String origFormat)
Create an instance of this date formatting class
Strftime(String,Locale)
Strftime
public Strftime(String origFormat,
Locale locale)
Create an instance of this date formatting class
origFormat
- the strftime-style formatting stringlocale
- the locale to use for locale-specific conversions
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.
pattern
- The pattern to search
- The modified pattern
format
public String format(Date date)
Format the date according to the strftime-style string given in the constructor.
date
- the date to format
- the formatted date
getTimeZone
public TimeZone getTimeZone()
Get the timezone used for formatting conversions
- the timezone
quote
protected String quote(String str,
boolean insideQuotes)
setTimeZone
public void setTimeZone(TimeZone timeZone)
Change the timezone used to format dates
SimpleDateFormat.setTimeZone
translateCommand
protected boolean translateCommand(StringBuffer buf,
String pattern,
int index,
boolean oldInside)
try to get the Java Date/Time formating associated with
the C standard provided
- The Java formatting rule to use
Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.