Java how to set 2011-11-06T14:34:16.679+02:00 into XMLGregorianCalendar

前端 未结 1 1331
你的背包
你的背包 2021-01-28 02:31

im building JAXWS client , one of the methods get XMLGregorianCalendar . now i need to format this data 2011-11-06T14:34:16.679+02:00 to be set into XMLGregorian

相关标签:
1条回答
  • 2021-01-28 03:32

    You can parse the date string into an java.util.Date object using follow method:

    String strDate = "2011-11-06T14:34:16.679+02:00";
    strDate = strDate.substring(0, 26) + strDate.substring(27, 29);
    
    String pattern = "yyyy-MM-dd'T'hh:mm:ss.SSSZ";
    SimpleDateFormat sdFormat = new SimpleDateFormat(pattern);
    
    Date d = sdFormat.parse(strDate);
    

    Then set this Date into your XMLGregorianCalendarj

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