I have a variable of type date in the format MM/dd/yyyy
. I need to convert the tempdate to xmlgregoriancalendar type in the same format i.e., MM/dd/yyyy
XMLGregorianCalendar
doesn't really "have" a format - or rather, it's not part of the data in the object, because the XML format for dates/times is specified in a particular format. So the request of "I need to convert the tempdate to xmlgregoriancalendar type in the same format i.e., MM/dd/yyyy" makes no sense, really.
If you want to get a different textual representation as a string, I suggest you use toGregorianCalendar() to get a java.util.Calendar
- then you can get the java.util.Date
and use an appropriately constructed SimpleDateFormat
to do the formatting.