How to parse toString date value to Date object
I have some issue with toString date value parse to Date object. here is my solution for that.
try { Date cutterntTime = new Date(); String dateStringValue = cutterntTime.toString(); //String dateStringValue = Thu May 05 11:26:49 IST 2011; DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); Date date = (Date)formatter.parse(dateStringValue); System.out.println("Date Value is : " + date); } catch (ParseException e){ System.out.println("Exception :"+e); }
Comments