Not Duplicate: I intended for this question to address the java.lang.IllegalArgumentException
that is thrown when attempting to add a formatted date back to a ParseObject
for rendering purposes.
I've got a list of dates which I want to display in a more readable format when I render them to my page. i.e. I want Wed Mar 29 13:32:35 CEST 2017
to become Wed Mar 29
.
for (ParseObject requestObject: requestsArrayList) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = sdf.parse(sdf.format(requestObject.getDate(ParseConstantsUtil.REQUEST_DATE_REQUESTED)));
log.info(String.valueOf(date));
} catch (java.text.ParseException e1) {
e1.printStackTrace();
}
requestObject.add(ParseConstantsUtil.REQUEST_DATE_REQUESTED, date);
}
requestObject.add(ParseConstantsUtil.REQUEST_DATE_REQUESTED, date);
I thought SimpleDateFormat
would be enough but I can't ditch the additional timestamp info and add the object back to my collection. What should I do?
Exception:
java.lang.IllegalArgumentException: not implemented!
at org.parse4j.operation.AddOperation.apply(AddOperation.java:26) ~[parse4j-1.5-SNAPSHOT.jar:na]
at org.parse4j.ParseObject.performOperation(ParseObject.java:375) ~[parse4j-1.5-SNAPSHOT.jar:na]
at org.parse4j.ParseObject.addAll(ParseObject.java:301) ~[parse4j-1.5-SNAPSHOT.jar:na]
at org.parse4j.ParseObject.add(ParseObject.java:296) ~[parse4j-1.5-SNAPSHOT.jar:na]
at com.nnit.automation.controller.IndexController.findRequestsByCurrentUser(IndexController.java:117) ~[classes/:na]
at com.nnit.automation.controller.IndexController.findRequestsByCurrentUser(IndexController.java:61) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
We can always convert the date to string in the needed format and add to requestObject
Sample Updated
for (ParseObject requestObject: requestsArrayList) {
SimpleDateFormat sdf2 = new SimpleDateFormat("E MMM dd");
String date = null;
try {
date = sdf.format(requestObject.getDate(ParseConstantsUtil.REQUEST_DATE_REQUESTED));
log.info(String.valueOf(date));
} catch (java.text.ParseException e1) {
e1.printStackTrace();
}
requestObject.add(ParseConstantsUtil.REQUEST_DATE_REQUESTED, date);
}