xmlgregoriancalendar formatting in MM/dd/yyyy

后端 未结 1 881
一生所求
一生所求 2021-01-26 17:02

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

相关标签:
1条回答
  • 2021-01-26 17:38

    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.

    0 讨论(0)
提交回复
热议问题