org.apache.catalina.util

Class 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: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $

Author: Bip Thelin Dan Sandberg

Field Summary
protected SimpleDateFormatsimpleDateFormat
protected static Propertiestranslate
Constructor Summary
Strftime(String origFormat)
Create an instance of this date formatting class
Strftime(String origFormat, Locale locale)
Create an instance of this date formatting class
Method Summary
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 conversions
protected Stringquote(String str, boolean insideQuotes)
voidsetTimeZone(TimeZone timeZone)
Change the timezone used to format dates
protected booleantranslateCommand(StringBuffer buf, String pattern, int index, boolean oldInside)
Try to get the Java Date/Time formatting associated with the C standard provided.

Field Detail

simpleDateFormat

protected SimpleDateFormat simpleDateFormat

translate

protected static Properties translate

Constructor Detail

Strftime

public Strftime(String origFormat)
Create an instance of this date formatting class

See Also: Strftime

Strftime

public Strftime(String origFormat, Locale locale)
Create an instance of this date formatting class

Parameters: origFormat the strftime-style formatting string locale the locale to use for locale-specific conversions

Method Detail

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

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

quote

protected String quote(String str, boolean insideQuotes)

setTimeZone

public void setTimeZone(TimeZone timeZone)
Change the timezone used to format dates

See Also: SimpleDateFormat#setTimeZone

translateCommand

protected boolean translateCommand(StringBuffer buf, String pattern, int index, boolean oldInside)
Try to get the Java Date/Time formatting associated with the C standard provided.

Parameters: buf The buffer pattern The date/time pattern index The char index oldInside Flag value

Returns: True if new is inside buffer

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.