Question

    DateFormat format = new SimpleDateFormat("ddMMMyyyy(E)",Locale.ENGLISH);  
    try {
        Date date = format.parse("26Mar2009(thur)");
        System.out.println(date.getDate());
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

the error is :java.text.ParseException: Unparseable date: "26Mar2009(thur)" but it can parse "26Mar2009(thu)", so i want to know how to parse "26Mar2009(thur)"?

Était-ce utile?

La solution

"Thur" isn't a valid value for the day name in week, a three-letter representation is expected. So I would suggest to normalize that before parsing the date, e.g. by just replacing "thur" with "thu".

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top