Java parsing date with timezone from a string
问题 I want to parse a date with timezone from a string in the format "31-12-2014 18:09 +05:30" . I tried to parse using simple-Date-Format using "d-MM-yyyy HH:mm ZZ" and "d-MM-yyyy HH:mm Z" . But it is giving me a un-parables date exception. How to do this? Please help me. 回答1: SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm XXX"); Date d = sdf.parse("31-12-2014 18:09 +05:30"); System.out.println(d); Note that you can't use X before SimpleDateFormat of JDK7, because it's the ISO