开发者

String to Date Parsing not working

开发者 https://www.devze.com 2023-01-07 02:21 出处:网络
I am getting date as string as a parameter from 开发者_JS百科Servlet. Now when I am trying to parse it again to get util.Date, it gives me error.

I am getting date as string as a parameter from 开发者_JS百科Servlet. Now when I am trying to parse it again to get util.Date, it gives me error.

I am getting string "Fri Jul 02 00:00:00 IST 2010" & I want util.Date from it. Tried SimpleDateFormat, DateFormat but didn't work.


The exact date format of your string-represented date is:

DateFormat df = new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy");

But I would suggest on configuring your custom format, and use it for converting back and forth.


As long as you set the format of your date string, it should work:

Parsing a date using a custom format

My guess is that you don't have the SimpleDateFormat string set properly. Try starting with a simple date String (dd/MM/yyyy) and seeing if you can get that to work.

0

精彩评论

暂无评论...
验证码 换一张
取 消