19 May 2004 - java_dev (original) (raw)

I just got bitten by a platform difference and wanted to share what I learned. In my current job, I write my java code using Windows and deploy it to AIX. This has worked for over a year.

Today I wasted six hours tracking down a bug, thinking it was data-related (the code imports JDEdwards data, alters it a but, then stores it in some Oracle tables. The problem turned out to be a difference in how AIX handles Calendar.set() and had nothing to do with the data.

( a very short test class to demonstrateCollapse )

Note: The two println statements returns the same date Windows, but different dates on AIX. The date returned by AIX is the current month and day, but the year is taken from the arg entered on the command line. It seems that setting the year causes the month and day to become 'today'.

The difference is that in the first case, Calendar.YEAR is set before Calendar.DAY_OF_YEAR and in the second case, Calendar.DAY_OF_YEAR is set before Calendar.YEAR.