Package org.apache.log4j.helpers
Class DateLayout
- java.lang.Object
-
- org.apache.log4j.Layout
-
- org.apache.log4j.helpers.DateLayout
-
public abstract class DateLayout extends Layout
This abstract layout takes care of all the date related options and formatting work.
-
-
Field Summary
Fields Modifier and Type Field Description protected Date
date
static String
DATE_FORMAT_OPTION
Deprecated.Options are now handled using the JavaBeans paradigm.protected DateFormat
dateFormat
static String
NULL_DATE_FORMAT
String constant designating no time information.protected FieldPosition
pos
static String
RELATIVE_TIME_DATE_FORMAT
String constant designating relative time.static String
TIMEZONE_OPTION
Deprecated.Options are now handled using the JavaBeans paradigm.-
Fields inherited from class org.apache.log4j.Layout
LINE_SEP, LINE_SEP_LEN
-
-
Constructor Summary
Constructors Constructor Description DateLayout()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
activateOptions()
void
dateFormat(StringBuffer buf, LoggingEvent event)
String
getDateFormat()
Returns value of the DateFormat option.String[]
getOptionStrings()
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method.String
getTimeZone()
Returns value of the TimeZone option.void
setDateFormat(String dateFormat)
The value of the DateFormat option should be either an argument to the constructor ofSimpleDateFormat
or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.void
setDateFormat(String dateFormatType, TimeZone timeZone)
Sets the DateFormat used to format date and time in the time zone determined bytimeZone
parameter.void
setDateFormat(DateFormat dateFormat, TimeZone timeZone)
Sets theDateFormat
used to format time and date in the zone determined bytimeZone
.void
setOption(String option, String value)
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method.void
setTimeZone(String timeZone)
The TimeZoneID option is a time zone ID string in the format expected by theTimeZone.getTimeZone(java.lang.String)
method.-
Methods inherited from class org.apache.log4j.Layout
format, getContentType, getFooter, getHeader, ignoresThrowable
-
-
-
-
Field Detail
-
NULL_DATE_FORMAT
public static final String NULL_DATE_FORMAT
String constant designating no time information. Current value of this constant is NULL.- See Also:
- Constant Field Values
-
RELATIVE_TIME_DATE_FORMAT
public static final String RELATIVE_TIME_DATE_FORMAT
String constant designating relative time. Current value of this constant is RELATIVE.- See Also:
- Constant Field Values
-
DATE_FORMAT_OPTION
@Deprecated 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.- See Also:
- Constant Field Values
-
TIMEZONE_OPTION
@Deprecated 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.- See Also:
- Constant Field Values
-
pos
protected FieldPosition pos
-
dateFormat
protected DateFormat dateFormat
-
date
protected Date date
-
-
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
@Deprecated public String[] getOptionStrings()
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method.
-
getTimeZone
public String getTimeZone()
Returns value of the TimeZone option.
-
setDateFormat
public void setDateFormat(DateFormat dateFormat, TimeZone timeZone)
Sets theDateFormat
used to format time and date in the zone determined bytimeZone
.
-
setDateFormat
public void setDateFormat(String dateFormat)
The value of the DateFormat option should be either an argument to the constructor ofSimpleDateFormat
or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.
-
setDateFormat
public void setDateFormat(String dateFormatType, TimeZone timeZone)
Sets the DateFormat used to format date and time in the time zone determined bytimeZone
parameter. TheDateFormat
used will depend on thedateFormatType
.The recognized types are
NULL_DATE_FORMAT
,RELATIVE_TIME_DATE_FORMAT
AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT
,AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT
andAbsoluteTimeDateFormat.ISO8601_DATE_FORMAT
. If thedateFormatType
is not one of the above, then the argument is assumed to be a date pattern forSimpleDateFormat
.
-
setOption
@Deprecated public void setOption(String option, String value)
Deprecated.Use the setter method for the option directly instead of the genericsetOption
method.
-
setTimeZone
public void setTimeZone(String timeZone)
The TimeZoneID option is a time zone ID string in the format expected by theTimeZone.getTimeZone(java.lang.String)
method.
-
-