Convert Java Date into XML Date Format (and vice versa)

后端 未结 9 1659
后悔当初
后悔当初 2020-12-03 10:46

Is there a nice and easy way to convert a Java Date into XML date string format and vice versa?

Cheers,

Andez

9条回答
  •  忘掉有多难
    2020-12-03 11:05

    As already suggested use SimpleDateFormat.

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    String date = sdf.format(new Date());
    System.out.println(date);
    Date d = sdf.parse(date);
    

    My guess is that the format/pattern that your looking for is yyyy-MM-dd'T'HH:mm:ss Also have a look at http://www.w3schools.com/schema/schema_dtypes_date.asp

提交回复
热议问题