Unexpected java SimpleDateFormat parse exception

前端 未结 3 710
春和景丽
春和景丽 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:42

    Works for me.

    public class Main {
    
    public static void main(String[] args)
    {
        time_print("Tue Mar 31 06:09:00 CEST 2009");
    }
    
    static Date submissionT;
    static SimpleDateFormat tempDate = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy");
    
    public static void time_print(String time) {
        try {
          submissionT=tempDate.parse(time);
          System.out.println(submissionT);
        }
        catch (Exception e) {
          System.out.println(e.toString() + ", " + time);
        }
    
    }
    

    }

提交回复
热议问题