org.apache.log4j.helpers

Class DateLayout

public abstract class DateLayout extends Layout

This abstract layout takes care of all the date related options and formatting work.

Author: Ceki Gülcü

Field Summary
protected Datedate
protected DateFormatdateFormat
static StringDATE_FORMAT_OPTION
static StringNULL_DATE_FORMAT
String constant designating no time information.
protected FieldPositionpos
static StringRELATIVE_TIME_DATE_FORMAT
String constant designating relative time.
static StringTIMEZONE_OPTION
Method Summary
voidactivateOptions()
voiddateFormat(StringBuffer buf, LoggingEvent event)
StringgetDateFormat()
Returns value of the DateFormat option.
String[]getOptionStrings()
StringgetTimeZone()
Returns value of the TimeZone option.
voidsetDateFormat(String dateFormat)
The value of the DateFormat option should be either an argument to the constructor of SimpleDateFormat or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.
voidsetDateFormat(DateFormat dateFormat, TimeZone timeZone)
Sets the DateFormat used to format time and date in the zone determined by timeZone.
voidsetDateFormat(String dateFormatType, TimeZone timeZone)
Sets the DateFormat used to format date and time in the time zone determined by timeZone parameter.
voidsetOption(String option, String value)
voidsetTimeZone(String timeZone)
The TimeZoneID option is a time zone ID string in the format expected by the TimeZone#getTimeZone method.

Field Detail

date

protected Date date

dateFormat

protected DateFormat dateFormat

DATE_FORMAT_OPTION

public static final String DATE_FORMAT_OPTION

Deprecated: Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

NULL_DATE_FORMAT

public static final String NULL_DATE_FORMAT
String constant designating no time information. Current value of this constant is NULL.

pos

protected FieldPosition pos

RELATIVE_TIME_DATE_FORMAT

public static final String RELATIVE_TIME_DATE_FORMAT
String constant designating relative time. Current value of this constant is RELATIVE.

TIMEZONE_OPTION

public static final String TIMEZONE_OPTION

Deprecated: Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

Method Detail

activateOptions

public void activateOptions()

dateFormat

public void dateFormat(StringBuffer buf, LoggingEvent event)

getDateFormat

public String getDateFormat()
Returns value of the DateFormat option.

getOptionStrings

public String[] getOptionStrings()

Deprecated: Use the setter method for the option directly instead of the generic setOption method.

getTimeZone

public String getTimeZone()
Returns value of the TimeZone option.

setDateFormat

public void setDateFormat(String dateFormat)
The value of the DateFormat option should be either an argument to the constructor of SimpleDateFormat or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.

setDateFormat

public void setDateFormat(DateFormat dateFormat, TimeZone timeZone)
Sets the DateFormat used to format time and date in the zone determined by timeZone.

setDateFormat

public void setDateFormat(String dateFormatType, TimeZone timeZone)
Sets the DateFormat used to format date and time in the time zone determined by timeZone parameter. The DateFormat used will depend on the dateFormatType.

The recognized types are NULL_DATE_FORMAT, RELATIVE_TIME_DATE_FORMAT ABS_TIME_DATE_FORMAT, DATE_AND_TIME_DATE_FORMAT and ISO8601_DATE_FORMAT. If the dateFormatType is not one of the above, then the argument is assumed to be a date pattern for SimpleDateFormat.

setOption

public void setOption(String option, String value)

Deprecated: Use the setter method for the option directly instead of the generic setOption method.

setTimeZone

public void setTimeZone(String timeZone)
The TimeZoneID option is a time zone ID string in the format expected by the TimeZone#getTimeZone method.
Copyright 2000-2005 Apache Software Foundation.