Not necessarily the most convincing use case, but the following fails,
import org.apache.log4j.*; import org.apache.log4j.helpers.*; import java.text.*; import java.util.*;
public class CDF {
protected static FieldPosition pos = new FieldPosition(0);
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MMMM-dd HH:mm:ss,SS Z");
CachedDateFormat cdf1 = new CachedDateFormat(sdf1);
StringBuffer buf = new StringBuffer();
Calendar c = Calendar.getInstance(); c.set(2004, Calendar.DECEMBER, 12, 20, 0); c.set(Calendar.SECOND, 37); c.set(Calendar.MILLISECOND, 23);
cdf1.format(c.getTime(), buf, pos); System.out.println(buf.toString()); buf.setLength(0);
cdf1.format(c.getTime(), buf, pos); System.out.println(buf.toString()); buf.setLength(0);
c.set(2005, Calendar.JANUARY, 1, 0, 0); c.set(Calendar.SECOND, 13); c.set(Calendar.MILLISECOND, 905);
cdf1.format(c.getTime(), buf, pos); System.out.println(buf.toString()); buf.setLength(0);
cdf1.format(c.getTime(), buf, pos); System.out.println(buf.toString());
} }
It incorrectly outputs
2004-December-12 20:00:37,23 +0100 2004-December-12 20:00:37,023+0100 2005-January-01 00:00:13,905 +0100 2005-January-01 00:00:13,9905+0100
At this moment, I'm too tired to try to fully understand why it fails and how it could be fixed. More tomorrow.
-- Ceki Gülcü
The complete log4j manual: http://qos.ch/log4j/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]