What is the best way to convert XMLGregorianCalendar to MM/dd/yyyy hh:mm String?

前端 未结 5 729
无人共我
无人共我 2021-02-04 00:18

What is the best way to convert XMLGregorianCalendar objects to \'MM/dd/yyyy hh:mm\' String?

5条回答
  •  你的背包
    2021-02-04 00:49

    You can use toGregorianCalendar() method for this.

    E.g.:

    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm");
    String date = sdf.format(xmlGregorianCalendar.toGregorianCalendar().getTime());
    

    In case, you need to convert that calendar to different TimeZone and Locale, use toGregorianCalendar(TimeZone timezone, Locale aLocale, XMLGregorianCalendar defaults)

提交回复
热议问题