DateTimeFormatter class in Java 8 can be used for both of these purposes. Below methods try to provide the solution to these issues.
// df2 = DateTimeFormatter.ofPattern("ddd,MMMM,yy"); // more than two d causes error // df2 = DateTimeFormatter.ofPattern("ddd ...
I could provoke this error by trying to serialize an ISO compliant Datetime String into a Java object of type DateTimeFormatter.