Carol, thanks very much for your input. It really helps.
you are right! I ran 3 rounds of your code and got one
in the 3rd round:
ate: Tue Apr 05 23:24:52 EDT 2005
SSS: 04/05/2005 23:24:52.093
SS: 04/05/2005 23:24:52.93
S: 04/05/2005 23:24:52.93
I think I made a mistake of translating another problem into
this generic one. My orginial problem is: my web app grabs
data from a SQL server and the following is part of the code:
....
dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
Date date = (Date)columnValue;
System.out.println("date:" + date);
if (date != null) {
String d = dateFormat.format(date);
System.out.println("Formated: " + d);
....
The following is one date pulled from the database:
date:2005-04-03 16:05:28.11
Formated: 04/03/2005 16:05:28.110
I thought it was a generic
Java problem. Looks like I need to
find out why this happened in my specific environment.
I did another
test as follows:
public static void test2() throws Exception {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date myDate = sdf1.parse("2005-04-03 16:05:28.11");
SimpleDateFormat sdf2 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
SimpleDateFormat sdf3 = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.S");
System.out.println("Date: " + sdf1.format(myDate));
System.out.println("SSS: " + sdf2.format(myDate));
System.out.println("S: " + sdf3.format(myDate));
}
and I still got the corrects:
Date: 2005-04-03 16:05:28.011
SSS: 04/03/2005 16:05:28.011
S: 04/03/2005 16:05:28.11
Thanks very much for your help here!
Regards,
Pete