I've created some classes that get dates from an xml file. I'm using Date() to store the data and SimpleDateFormat to parse it.
I then need to add a number of seconds to the Date and compare it to another Date. Right now I'm using GregorianCalendar.add() and then converting back to a Date. I then use Date.after to compate them.
This all seems a bit complex to me. Might I not be further ahead to store the dates as longs, then simply add (seconds * 1000)? I could compare directly and would only need to treat them as dates on first reading them from the xml, and when displaying to the users.
If you're converting from a date to a calendar already - why not just compare the calendar objects (before/after). As a word of warning (because I got nailed by it recently), depending upon how you are reading your dates from XML, database, etc - you have to be careful of TimeZones because your dates can lose some hours. IMHO it's easiest to parse the date field as a Calendar from the XML, then always use Calendar for everything (add, and compares). Of course I'm using JAXB which reads dates from XML as Calendar (at least for the fields I'm using).