How to parse DateTime property from AppEngine in Java (Android)?

后端 未结 2 1352
傲寒
傲寒 2021-01-13 19:06

I need to parse DateTime string coming from AppEngine in Java (Android). The string looks like this: 2011-07-26 17:21:00+01:00. Is it some standard format? Is t

2条回答
  •  天命终不由人
    2021-01-13 19:55

    SimpleDateFormat is pretty simple except that for the fact that your date string is a bit off because of the last : in there. Just replace the : and use the following pattern:

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:ss:mmZ");
    String dateStr = "2011-07-26 17:21:00+0100";
    System.out.println(sdf.parse(dateStr));
    

提交回复
热议问题