java - Unparseable date exception when converting a string to "yyyy-MM-dd HH:mm:ss" -
Hi, I'm trying to convert a string 19611015 to a date format ("yyyy-MM-dd HH: mm: ss"
") Before trying to store it in a sibbase database table, I have tried the following code which gives me an error:
Unstarred date:" 19611015 " / P>
date format formattor = new simpledate format ("yyyy-MM-dd HH: mm: ss"); Println (formatter.parse ("19,611,015")); < P> I read some of its long and complex solutions Yes, some people suggest using some people: Can someone possibly convert an alternate simple solution into a string, I have a date format which I am in the above version. Thanks.
date is in yyyyMMdd format in the string and want to convert it to yyyy-MM-dd HH: Mm: ss then use the code below: dateFormat originalFormat = new SimpleDateFormat ("yyyyMMdd"); Date format target format = new simpleformformat ("yyy-mm-dd hh: mm: ss"); Date date = original format Prs ("19611015"); String formatteddet = target format. Format (date); Println (formattedDate); Output:
1 961-10-15 00:00:00
Comments
Post a Comment