0

I am have this String from a Date object: Mon Mar 25 00:00:00 IST 2013

What is the String representation of the date format?

Ashu
  • 392
  • 1
  • 7
  • 16
  • refer http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html and try something yourself before post a question – Never Quit Mar 21 '13 at 11:42
  • 1
    Please avoid asking questions that do not show any intent of research on your behalf. [What have you tried?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – RJo Mar 21 '13 at 11:43
  • **"EEE, MMM d, ''yy"** from [http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html] – subodh Mar 21 '13 at 11:44
  • You will find your answer in this subject [http://stackoverflow.com/questions/6636375/java-convert-date-formatted-string-from-sql-db-to-date-object-for-comparison][1] [1]: http://stackoverflow.com/questions/6636375/java-convert-date-formatted-string-from-sql-db-to-date-object-for-comparison – Tako Mar 21 '13 at 11:45

2 Answers2

6

The code below should work fine.

public static void main(String[] args) throws Exception {
    String target = "Mon Mar 25 00:00:00 IST 2013";
    DateFormat df = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy", Locale.ENGLISH);
    Date result =  df.parse(target);  
    System.out.println(result);
}

Read the javadoc for the valid patterns.

David
  • 19,577
  • 28
  • 108
  • 128
2
String yourDate= "Mon Mar 25 00:00:00 IST 2013" ;
DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
Date jDate = new Date(df.parse(yourDate).getTime());
System.out.println(jDate);
Sagar Dalvi
  • 200
  • 1
  • 9