« September 2009 | Main | November 2009 »
October 30, 2009
Robustness principle - Wikipedia, the free encyclopedia
http://en.wikipedia.org/wiki/Robustness_principle
Postel's robustness principle ("be conservative in what you send, liberal in what you accept"). One of my favorite engineering concepts.
Posted by aland at 5:41 PM | Comments (0) | TrackBack
October 1, 2009
Convert XML Date to Java Date using XmlCalendar!
http://xmlbeans.apache.org/docs/2.0.0/reference/org/apache/xmlbeans/XmlCalendar.html
I tried SO hard to get this working. FINALLY one of my coworkers (go Ben!) found this reference.
Code fragment below assumes:
1) 'dateStr' is a string containing an xs:dateTime format string
2) What you want out on the other side is a GregorianCalendar whose time is the same as the time represented by dateStr.
public GregorianCalendar convXmlDateToGregorianCalendar(String dateStr) {
XmlCalendar xCal = new XmlCalendar(dateStr);
GregorianCalendar gCal = new GregorianCalendar();
gCal.setTime(xCal.getTime());
return gCal;
}
Code is transcribed, not cut & pasted, so YMMV - if it's off, let me know and I'll fix it.
Posted by aland at 9:34 AM | Comments (0) | TrackBack