|
Created an attachment (id=10738)
Jython script illustrating bug in java.Calendar I think you're right; I think this is a bug in java, or at least an undocumented feature since the
0-11 requirement for Calendar.HOUR is not in the javadocs. I just attached a jython script demonstrating this. (Jython is great for testing java classes this way). The script creates a Calendar, clears it, then sets its fields one by one. After each set the internals of the Calendar are printed out. All looks well until getTime() is called, after which the internals are messed up. I will shortly commit a fix to this problem. The fix will replace the use of Calendar.HOUR with I wonder how long this has been around. changed to figure 12:00 am and pm manually, and use Calendar.HOUR_OF_DAY instead of
Calendar.HOUR, due to what appears to be a bug in java.Calendar. also note that test updated to check for this. Previously this problem wasn't tested.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
java.util.Calendar instance returned by Calendar.getInstance() is 0 to 11. The
parseFTPEntry method of NTFTPEntryParser feeds the parsed hour component of the
FTP entry's timestamp as-is to the Calendar's HOUR field, which causes the
resulting Calendar value to "skip ahead" 12 hours from the intended value.
Note that, for example, raw data:
"02-19-04 12:24AM 10728307 FAUSLSILVS.00001"
results in Thu Feb 19 12:24:00 2004 rather than Thu Feb 19 00:24:00 2004.