SimpleDateFormat: A reason for more open source freedom with Java?
By bblfish on May 31, 2006
will produce a date like this
Whereas what I need for xml schema is
It would be relatively easy to just make a copy of the
class, rename it to
XSDDateFormat and make a few
adjustments. Then I would have what I need. But the code is copyrighted
by IBM, so it is probably untoucheable. Clearly rewriting the class
itself and allowing it to keep its name would lead to a lot of
confusion, and should not be allowed. But using the code itself should
cause no one any harm, when clearly moved into a different class.
Of course this is not the whole story in the open source argument for Java, but it should be a consideration.
Update: I found XMLGregorianCalendar in the javax.xml.datatype package, and after some serious searching on the web, I found out how to use it. So here:
GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(time.getTime()); DatatypeFactory df = DatatypeFactory.newInstance(); XMLGregorianCalendar xc = df.newXMLGregorianCalendar (gc); String ts = xc.toXMLFormat();
Kindof complicated really. But still, it works...
So what is the lesson now? That it is good that the code was not licenced liberally, because it forced me to find the right solution?