java : How can I cast Date from "Thu May 01 00:00:00 WEST 2014 " to "2014-01-05 00:00:00.0"
- by lilyana
How can I want to cast Date from "Thu May 01 00:00:00 WEST 2014 " to "2014-01-05 00:00:00.0"
I try with this code :
SimpleDateFormat toFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
String dateStr = getDtdebut().toString();
Date date = new Date();
try {
date = toFormat.parse(dateStr);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
but i have this error :
java.text.ParseException: Unparseable date: "Thu May 01 00:00:00 WEST 2014"
at java.text.DateFormat.parse(Unknown Source)
at ensa.pfe.action.GestionOperations.filtre(GestionOperations.java:386)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
..........