Timestamp to string date
String S = "1350574775";
You are sending your timestamp in seconds, instead of milliseconds.
Do this, instead:
String S = "1350574775000";
Or, in your getDate
method, multiply by 1000L
:
new Date(Long.parseLong(timeStampStr) * 1000L)
try this if you're sticking with "1350574775" format which is in seconds:
private void onCreate(Bundle bundle){
....
String S = "1350574775";
//convert unix epoch timestamp (seconds) to milliseconds
long timestamp = Long.parseLong(s) * 1000L;
czas.setText(getDate(timestamp ));
}
private String getDate(long timeStamp){
try{
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Date netDate = (new Date(timeStamp));
return sdf.format(netDate);
}
catch(Exception ex){
return "xx";
}
}