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);
     }




Post a Comment

Popular posts from this blog

Yield Price Sri Lanka - Android Application

Manage SOAPAction of the Out Message

Remove duplicate XML elements using XSLT