XMLAdapter: Configurable Date Format

NewMaxx

New Member
I'm unmarshaling XML data using JAXB (and a little Saxon for XSLTs). In my XML document I have a date string value.I did some research and experimented with XMLAdapter and @XMLJavaTypeAdapter. I found a useful Q&A on StackOverflow here: jaxb unmarshal timestamp. The solution outlined there involving a SimpleDateFormat seems to work well.Here is my problem: The format of the date string in the XML is variable from document to document. It can be in a different date format each time. In the current system (that I am replacing with all this XML manipulation) there are date formats in database tables that are retrieved and applied when the XML document is parsed. Manually. Line by line. (Now you see why I'm replacing it with JAXB, yeesh!)So the question would be: How would I change out the date format string being fed to the SimpleDateFormat in the XMLAdapter for different documents? Is such a thing even possible? Am I doomed to reading the date string out as a String and then converting it to a Date somewhere else later on?Edit: I was just going to delete this question, but it got up-voted, so I guess I'll write out a proper answer to it as to what I ended up doing. I'm going to hold off on accepting my own answer for awhile, in case anyone has some insight that leads to an even better answer.
 
Back
Top