Wednesday, 11 September 2013

Transform Date to SimpleDateFormat

Transform Date to SimpleDateFormat

I'm getting an XMLGregorianCalendar from a rest service. I need to
localize the months depending on the language. I've read that the best way
to localize a date is by using the SimpleDateFormat class. The thing is
that I'm not sure how to transform an XMLGregorianCalendar to a
SimpleDateFormat. Casting doesn't work, and the closest I can get is
XMLGregorianCalendar.toGregorianCalendar.getTime() which returns a Date,
but I can't find a way to transform a Date to a SimpleDateFormat type. Any
ideas?
-EDIT- The reason why I like the SimpleDateFormat is because I can use the
List of ISO 639-1 codes
(http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), which is what I
get from my context.

No comments:

Post a Comment