java.text.ParseException: Unparseable date: convert mm/dd/yyyy string to a date

前端 未结 4 1990
南方客
南方客 2021-01-03 04:18

when i convert my string object in mm/dd/yyyy format to Date it gives me

java.text.ParseException: Unparseable date: \"09/17/2014         


        
4条回答
  •  萌比男神i
    2021-01-03 05:13

    You have mixed m and M.

    mstands for minute and M for month.

    Below is an example of a working format.

    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
    String dateInString = "07/06/2013"; 
    Date date = formatter.parse(dateInString);
    System.out.println(formatter.format(date));
    

提交回复
热议问题