I am having a bit of trouble parsing a timestamp string brought back from the server using JSON. I am using the following code to extract the timestamp from a HashMap and display it in the Log:
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Long time = Long.parseLong(event.get("time"));
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(time);
String event_date = sdf.format(cal.getTime());
Log.v("Date", event_date);
But for every timestamp I pass into this method it brings back the date 16th Jan 1970, an example of a timestamp that I am trying to parse is 1336773600 which should correspond to the 11th May 2012. I can't see what I am doing wrong here but obviously I am. Any suggestions?
eventobject you are using? Is it possible it is not, in fact, returning time in milliseconds?