URL:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=13191>
Summary: java.util.Calendar broken with certain operations
Project: classpath
Submitted by: manawiz
Submitted on: Thu 05/26/2005 at 04:39
Category: classpath
Severity: 3 - Normal
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Platform Version: Windows XP
_______________________________________________________
Details:
The following sequence of statements illustrates a bug in Calendar:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
Calendar cal = Calendar.getInstance();
cal.set(2005, 4, 25, 20, 50, 30);
cal.set(Calendar.MILLISECOND, 333);
Date date = cal.getTime();
Calendar ccal = Calendar.getInstance();
ccal.setTime(new Date(date.getTime()));
System.out.println(df.format(ccal.getTime()));
ccal.set(Calendar.MONTH, 0);
System.out.println(df.format(ccal.getTime()));
The output is:
2005-05-25 20:50:30:333
1970-01-01 00:00:00:000
But should be:
2005-05-25 20:50:30:333
2005-01-25 20:50:30:333
Many variations of the above work. I encountered this from a failing Lucene
JUnit test. Other that this, Lucene works with GNU Classpath. However, the
above breaks Lucene's DateTools, which are routinely used for time-tagging
indexed documents.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=13191>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
_______________________________________________
Commit-classpath mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/commit-classpath