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

前端 未结 5 717
无人共我
无人共我 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:51

    This is an example you are looking for:

    XMLGregorianCalendar date = ...; // initialization is out of scope for this example
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm");
    GregorianCalendar gc = date.toGregorianCalendar();
    String formatted_string = sdf.format(gc.getTime());
    

提交回复
热议问题