java SimpleDateFormat

后端 未结 4 1549
甜味超标
甜味超标 2020-12-15 23:51

in Java, how to parse a date string that contains a letter that does not represent a pattern?

\"2007-11-02T14:46:03+01:00\"
String date =\"2007-11-0         


        
4条回答
  •  清酒与你
    2020-12-16 00:40

    The time you're trying to parse appears to be in ISO 8601 format. SimpleDateFormat unfortunately doesn't support all the same timezone specifiers as ISO 8601. If you want to be able to properly handle all the forms specified in the ISO, the best thing to do is use Joda time.

    This example is straight out of the user guide:

    DateTime dt = new DateTime("2004-12-13T21:39:45.618-08:00");
    

提交回复
热议问题