Fri Mar 30 00:00:00 CET 14 to dd/mm/yyyy

扶醉桌前 提交于 2019-12-20 06:07:20

问题


I try to parse format date Fri Mar 30 00:00:00 CET 14 to dd/mm/yyyy

this is my code

   SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
   System.out.println(formatter.parse(date_retour.toString()));

error java.text.ParseException: Unparseable date: "Fri Mar 30 00:00:00 CET 14"

help please

it is okay now

    try {
        SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z", Locale.ENGLISH);  
        SimpleDateFormat formatter2 = new SimpleDateFormat("dd-MM-yyyy");  
        Date date;
        date = formatter.parse(date_retour.toString());
        donnees [i][9]  =formatter2.format(date);
    } catch (ParseException ex) {
        Logger.getLogger(operation2.class.getName()).log(Level.SEVERE, null, ex);
    }

回答1:


You need to match the date format pattern with the input String

SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z", Locale.ENGLISH); 


来源:https://stackoverflow.com/questions/22850574/fri-mar-30-000000-cet-14-to-dd-mm-yyyy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!