SimpleDateFormat: unparseable date exception

后端 未结 2 1384
挽巷
挽巷 2021-01-18 04:08

After looking after several existing posts, I am still not able to get my SimpleDateFormat parser working. Here is the code:

SimpleDateFormat df = new Simple         


        
2条回答
  •  走了就别回头了
    2021-01-18 04:36

    Here is the solution:

                SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
            try {
                volcanoListDate = df.parse(currentValue.replaceAll("\\p{Cntrl}", ""));
            } catch (ParseException e) {
                Log.d("VOLCANO_DEBUG", e.toString());
                Log.d("VOLCANO_DEBUG", currentValue);
            }
    

    The important change is .replaceAll("\\p{Cntrl}", "") which removes control characters from the parsed string. The strange thing is, that I do not see any of those characters with Notepad++ in the xml where the string is from. However, obviously there is something and it is working now.

    Thanks for all the help!

提交回复
热议问题