23/12/2013 is mapping with MM/dd/yyyy format why, why not ParseException

后端 未结 5 554
野性不改
野性不改 2021-01-28 10:20

Can anybody help?

public void dateCalender() throws ParseException{
        System.out.println(new SimpleDateFormat(\"MM/dd/yyyy\", Locale.ENGLISH).parse(\"120/1         


        
5条回答
  •  不思量自难忘°
    2021-01-28 10:52

    You have to invoke setLenient with false - otherwise SimpleDateFormat will try to "figure out" what month that is. So, first create SimpleDateFormat and invoke sdf.setLenient(false). Now when parsing, you will get exception.

提交回复
热议问题