I'm trying to work out a better way of converting a date that is in the form of a gregorian calendar into an XML so later it is easy to get it back. I'm trying to avoid parsing the date out if I can avoid it.
The date is implemented in a class as
GregorianCalendar dateOfBirth;
public void setDateOfBirth(GregorianCalendar dateIn ){
this.dateOfBirth = dateIn;
}
public GregorianCalendar getDOB(GregorianCalendar dateIn ){
return this.dateOfBirth;
}
//To set the date of birth
newStudent.setDateOfBirth(new GregorianCalendar(dobYEAR, dobMON, dobDAY));
Currently I am sending the XML a string using
documentModel.createTextNode(thisStudent.toStringDOB());
Which sends a string
05/09/1984
This would be fine for a display but, when I read the XML back I want to store it as gregorian calendar. Im sure I can break it down to ints of month day and year then send those individually into the XML with something to the effect like this
documentModel.createTextNode(thisStudent.getDOBday().toString());
documentModel.createTextNode(thisStudent.getDOBmonth().toString());
documentModel.createTextNode(thisStudent.getDOByear().toString());
And when I parse the XML back in i could set a new gregorian date. But would like to do something simple like.
documentModel.createTextNode(thisStudent.getDOB().toString());
Where there would be only one item that needs to be delt with on both ends. But the toString method for calendar/gregorian calendar is not useful for the situation I need.