in src/main/java/org/apache/log4j/pattern/DatePatternConverter.java [112:163]
private DatePatternConverter(final String[] options) {
super("Date", "date");
String patternOption;
if ((options == null) || (options.length == 0)) {
// the branch could be optimized, but here we are making explicit
// that null values for patternOption are allowed.
patternOption = null;
} else {
patternOption = options[0];
}
String pattern;
if (
(patternOption == null)
|| patternOption.equalsIgnoreCase(ISO8601_FORMAT)) {
pattern = ISO8601_PATTERN;
} else if (patternOption.equalsIgnoreCase(ABSOLUTE_FORMAT)) {
pattern = ABSOLUTE_TIME_PATTERN;
} else if (patternOption.equalsIgnoreCase(DATE_AND_TIME_FORMAT)) {
pattern = DATE_AND_TIME_PATTERN;
} else {
pattern = patternOption;
}
int maximumCacheValidity = 1000;
DateFormat simpleFormat = null;
try {
simpleFormat = new SimpleDateFormat(pattern);
maximumCacheValidity = CachedDateFormat.getMaximumCacheValidity(pattern);
} catch (IllegalArgumentException e) {
LogLog.warn(
"Could not instantiate SimpleDateFormat with pattern "
+ patternOption, e);
// default to the ISO8601 format
simpleFormat = new SimpleDateFormat(ISO8601_PATTERN);
}
// if the option list contains a TZ option, then set it.
if ((options != null) && (options.length > 1)) {
TimeZone tz = TimeZone.getTimeZone((String) options[1]);
simpleFormat.setTimeZone(tz);
} else {
simpleFormat = new DefaultZoneDateFormat(simpleFormat);
}
df = new CachedDateFormat(simpleFormat, maximumCacheValidity);
}