Pergunta

    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)"?

Foi útil?

Solução

"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".

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top