Dates in Java.
Can anyone tell me why the Calendar class and the SimpleDateFormat class have so little to do with each other. For this uber-date selector widget that I'm producing I am using a date formatting string, based on SimpleDateFormat's, to tell the control what and how to display, I am also using a Calendar object to deal with the date arithmetic, i.e. rolling from 31st of December to 1st January in the next year.
I've had to build my own date format parser, because there is now way I can find to extract useful information about the date format string from SimpleDateFormat and absolutely no way to get useful textual descriptions of dates out of the Calendar without formatting a complete date.
What is worse is things like the Calendar returning int 0 for the value of January when getting the value of hte month field. I can understand that this is an index of the date, but this is not how any of the other fields work, and quite frankly my view on the matter is that 1 should be value of the month field for January.
Well I've gotten around most of these inconsistencies, for a start my date selector only deals with numerical representations of dates for now. I've created a calendar adaptor which sorts out the month offset problem and also now has get and set field value by string methods, which nicely handles the Era problem, BC=0 and AD=1.
I know that some of these issues are specific to the type of problem that I'm dealing with, but I am sure some of you must also have come across these. I had a scan through the Java bug database for Calendar bugs, but there were far too many to go through looking for these ones.
Dates are a big problem, one of the most recurring problems I have to deal with, but the Java core should be better than this. I won't tell you what we did when storing dates in the database, that's just evil!! ;)