Top Description Fields Constructors Methods
org.apache.catalina.util

public Class Strftime

extends Object
Class Inheritance
Imports
java.text.SimpleDateFormat, java.util.Date, .Locale, .Properties, .TimeZone

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.
Authors
Bip Thelin, Dan Sandberg

Field Summary

Modifier and TypeField and Description
protected final SimpleDateFormat
protected static final Properties

Constructor Summary

AccessConstructor and Description
public
Strftime(String
the strftime-style formatting string
origFormat
,
Locale
the locale to use for locale-specific conversions
locale
)

Create an instance of this date formatting class

Method Summary

Modifier and TypeMethod and Description
protected String

Returns:

The modified pattern
convertDateFormat
(String
The pattern to search
pattern
)

Search the provided pattern and get the C standard Date/Time formatting rules and convert them to the Java equivalent.

public String

Returns:

the formatted date
format
(Date
the date to format
date
)

Format the date according to the strftime-style string given in the constructor.

public TimeZone

Returns:

the timezone
getTimeZone
()

Get the timezone used for formatting conversions

protected String
quote(String str, boolean insideQuotes)

public void
setTimeZone(TimeZone
The new time zone
timeZone
)

Change the timezone used to format dates

protected boolean

Returns:

True if new is inside buffer
translateCommand
(StringBuilder
The buffer
buf
,
String
The date/time pattern
pattern
,
int
The char index
index
,
boolean
Flag value
oldInside
)

Try to get the Java Date/Time formatting associated with the C standard provided.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

simpleDateFormatback to summary
protected final SimpleDateFormat simpleDateFormat
translateback to summary
protected static final Properties translate

Constructor Detail

Strftimeback to summary
public Strftime(String origFormat, Locale locale)

Create an instance of this date formatting class

Parameters
origFormat:String

the strftime-style formatting string

locale:Locale

the locale to use for locale-specific conversions

Method Detail

convertDateFormatback to summary
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:String

The pattern to search

Returns:String

The modified pattern

formatback to summary
public String format(Date date)

Format the date according to the strftime-style string given in the constructor.

Parameters
date:Date

the date to format

Returns:String

the formatted date

getTimeZoneback to summary
public TimeZone getTimeZone()

Get the timezone used for formatting conversions

Returns:TimeZone

the timezone

quoteback to summary
protected String quote(String str, boolean insideQuotes)
setTimeZoneback to summary
public void setTimeZone(TimeZone timeZone)

Change the timezone used to format dates

Parameters
timeZone:TimeZone

The new time zone

See Also
SimpleDateFormat#setTimeZone
translateCommandback to summary
protected boolean translateCommand(StringBuilder buf, String pattern, int index, boolean oldInside)

Try to get the Java Date/Time formatting associated with the C standard provided.

Parameters
buf:StringBuilder

The buffer

pattern:String

The date/time pattern

index:int

The char index

oldInside:boolean

Flag value

Returns:boolean

True if new is inside buffer