mercredi 25 mars 2015

How to converted timestamp string to a date in java

I have a string "1427241600000" and I want it converted to "yyyy-MM-dd" format.


I have tried, but I am not able to parse it, please review the below code



try {
String str = "1427241600000";
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
Date date =sf.parse(str);
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
}


I would like to know where I went wrong.


Aucun commentaire:

Enregistrer un commentaire