Unparsable date exception

前端 未结 5 1180
我在风中等你
我在风中等你 2021-01-21 21:37

I\'m currently working on some simple project in Java and I have date in the following string:

String dateString = \"Sun 7/14 03:44 AM 2013\";
         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 21:58

    It is important to add Locale as you are parsing language day of week names.

    String dateString = "Sun 7/14 03:44 AM 2013";
    DateFormat format = new SimpleDateFormat("EEE M/dd hh:mm a yyyy", Locale.US);
    Date d = format.parse(dateString);
    

提交回复
热议问题