aspose file tools*
The moose likes Java in General and the fly likes Calendar's day of week gets inconsistent case!? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Calendar Watch "Calendar New topic
Author

Calendar's day of week gets inconsistent case!?

Maverick Lasa
Greenhorn

Joined: Oct 18, 2003
Posts: 23
Hello Ranchers,
I happen to encounter this when I was coding for date type conversions.
I really don't have the hint why the day of the week is different as
well as the long value. But the value will be the same when the MARKED
LINE is commented out or setting the DEFAULT_YEAR's value to a value that
is greater than 0. Someone has any idea?

Regards,
Mavedrive
[ October 18, 2003: Message edited by: Maverick Lasa ]
[ October 18, 2003: Message edited by: Maverick Lasa ]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
GregorianCalendar does not have a year 0, nor any negative year for that matter. The correct representation of years prior to 1 AD is to set the ERA to BC. "Year 0" is 1 BC, while "year -1" would be 2 BC. Yes, this is pretty silly, but it's how the standard Gregorian calendar in the outside world was designed; GregorianCalendar merely reflects this. The GregorianCalendar class works correctly as long as you use legal values for the YEAR field; if you use 0 or negative values, it gives inconsistent results, as you've observed. The documentation for GregorianCalendar and Calendar is rather poor in this regard; they really should point out what the allowed values for year consist of. Further they really should throw IllegalArgumentExcecption when illegal arguments are used, rather than return inconsistent results. Of course, htis is just part of a long list of objections to the way Calendar is set up in Java. Oh well...
[ October 18, 2003: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Maverick Lasa
Greenhorn

Joined: Oct 18, 2003
Posts: 23
Thanks Jim,
I do agree that the javadoc is quite poor; not describing the range of valid values for the fields. Anyway, let's just hope it will be fixed in
the incoming versions...
Mavedrive
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calendar's day of week gets inconsistent case!?