Unexpected java SimpleDateFormat parse exception

前端 未结 3 703
春和景丽
春和景丽 2020-12-10 06:52

I can\'t understand why this few lines

    Date submissionT;
    SimpleDateFormat tempDate = new SimpleDateFormat(\"EEE MMM d HH:mm:ss z yyyy\");

    public         


        
3条回答
  •  暖寄归人
    2020-12-10 07:34

    The 'z' in your format represents TimeZone and Java only recognises certain timezone ID's. You can get the list out of the TimeZone class as a String Array. CEST does not appear in the list I just generated from JDK 1.5

    String[] aZones = TimeZone.getAvailableIDs();
        for (int i = 0; i < aZones.length; i++) {
            String string = aZones[i];
            System.out.println(string);
        }
    

    Hope this helps.

提交回复
热议问题