convert string into date format in java

前端 未结 3 1484
傲寒
傲寒 2021-01-24 16:50

I want to convert this string to the following date format.

  String s = \"2-26-2013\";
  Date date = new SimpleDateFormat(\"EEEE, MMMM/dd/yyyy\").parse(s);
  Sy         


        
3条回答
  •  滥情空心
    2021-01-24 17:16

    Date date = new SimpleDateFormat("MM-dd-yyyy").parse(s);
    

    The argument to SimpleDateFormat defines the format your date it in. The above line matches your format, and works. Your example does not match.

提交回复
热议问题