in src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java [816:840]
private String quoteTimeStampChars(String input) {
//put single quotes around text that isn't a supported dateformat char
StringBuilder result = new StringBuilder();
//ok to default to false because we also check for index zero below
boolean lastCharIsDateFormat = false;
for (int i = 0; i < input.length(); i++) {
String thisVal = input.substring(i, i + 1);
boolean thisCharIsDateFormat = VALID_DATEFORMAT_CHARS.contains(thisVal);
//we have encountered a non-dateformat char
if (!thisCharIsDateFormat && (i == 0 || lastCharIsDateFormat)) {
result.append("'");
}
//we have encountered a dateformat char after previously encountering a non-dateformat char
if (thisCharIsDateFormat && i > 0 && !lastCharIsDateFormat) {
result.append("'");
}
lastCharIsDateFormat = thisCharIsDateFormat;
result.append(thisVal);
}
//append an end single-quote if we ended with non-dateformat char
if (!lastCharIsDateFormat) {
result.append("'");
}
return result.toString();
}