Methods Summary |
---|
public void | activateOptions()
setDateFormat(dateFormatOption);
if(timeZoneID != null && dateFormat != null) {
dateFormat.setTimeZone(TimeZone.getTimeZone(timeZoneID));
}
|
public void | dateFormat(java.lang.StringBuffer buf, org.apache.log4j.spi.LoggingEvent event)
if(dateFormat != null) {
date.setTime(event.timeStamp);
dateFormat.format(date, buf, this.pos);
buf.append(' ");
}
|
public java.lang.String | getDateFormat()Returns value of the DateFormat option.
return dateFormatOption;
|
public java.lang.String[] | getOptionStrings()
return new String[] {DATE_FORMAT_OPTION, TIMEZONE_OPTION};
|
public java.lang.String | getTimeZone()Returns value of the TimeZone option.
return timeZoneID;
|
public void | setDateFormat(java.lang.String dateFormatType, java.util.TimeZone timeZone)Sets the DateFormat used to format date and time in the time zone
determined by timeZone parameter. The {@link DateFormat} used
will depend on the dateFormatType .
The recognized types are {@link #NULL_DATE_FORMAT}, {@link
#RELATIVE_TIME_DATE_FORMAT} {@link
AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT}, {@link
AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_FORMAT} and {@link
AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT}. If the
dateFormatType is not one of the above, then the
argument is assumed to be a date pattern for {@link
SimpleDateFormat}.
if(dateFormatType == null) {
this.dateFormat = null;
return;
}
if(dateFormatType.equalsIgnoreCase(NULL_DATE_FORMAT)) {
this.dateFormat = null;
} else if (dateFormatType.equalsIgnoreCase(RELATIVE_TIME_DATE_FORMAT)) {
this.dateFormat = new RelativeTimeDateFormat();
} else if(dateFormatType.equalsIgnoreCase(
AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT)) {
this.dateFormat = new AbsoluteTimeDateFormat(timeZone);
} else if(dateFormatType.equalsIgnoreCase(
AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT)) {
this.dateFormat = new DateTimeDateFormat(timeZone);
} else if(dateFormatType.equalsIgnoreCase(
AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT)) {
this.dateFormat = new ISO8601DateFormat(timeZone);
} else {
this.dateFormat = new SimpleDateFormat(dateFormatType);
this.dateFormat.setTimeZone(timeZone);
}
|
public void | setDateFormat(java.lang.String dateFormat)The value of the DateFormat option should be either an
argument to the constructor of {@link SimpleDateFormat} or one of
the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.
if (dateFormat != null) {
dateFormatOption = dateFormat;
}
setDateFormat(dateFormatOption, TimeZone.getDefault());
|
public void | setDateFormat(java.text.DateFormat dateFormat, java.util.TimeZone timeZone)Sets the {@link DateFormat} used to format time and date in the
zone determined by timeZone .
this.dateFormat = dateFormat;
this.dateFormat.setTimeZone(timeZone);
|
public void | setOption(java.lang.String option, java.lang.String value)
if(option.equalsIgnoreCase(DATE_FORMAT_OPTION)) {
dateFormatOption = value.toUpperCase();
} else if(option.equalsIgnoreCase(TIMEZONE_OPTION)) {
timeZoneID = value;
}
|
public void | setTimeZone(java.lang.String timeZone)The TimeZoneID option is a time zone ID string in the format
expected by the {@link TimeZone#getTimeZone} method.
this.timeZoneID = timeZone;
|