Hello Friends,
I'm having an issue that several hours of google searching and tweaking has been unable to resolve. I'm reading an XML file using
Java DOM. That part is working correctly. Each element within the file contains a date attribute that is in the format of "MM/DD/yyyy" e.g. "07/23/2013" I am trying to use a SimpleDateFormat object to parse the
string into a Calendar object. It correctly reads the day and year into the Calendar object, but always returns January (1) as the month. Here is the code I am using:
The SimpleDateFormat object's parse method returns a Date object, so here is my method to convert the Date object to a Calendar object:
Is there something I am missing or doing incorrectly?
EDIT:
I added the following line to the dateToCalendar method just to see what the output would be:
It prints out 0 when the month in the input string is "07". So it seems to me that the problem is with the SimpleDateFormat object and not the Date or Calendar objects, and not with the dateToCalendar method. Any ideas?