Getting date format in Java

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

What is a String format of a date format?

0
source share
2 answers

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 javadoc for valid patterns.

+6
source
 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); 
+2
source

All Articles