I have TimeStamp
time as String 1374160160
which is equivalent 07/18/2013
.
If there is a way how I can convert this TimeStamp to date with format July 18, 2013
?
This is my code snippet:
try{
String timeStamp = "1374160160";
DateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Date netDate = (new Date(timeStamp));
return sdf.format(netDate);
} catch(Exception ex) {
return "";
}
It always returns 01/17/1970
why?
The second problem is that new Date(String)
is deprecated.
To sum up:
How to create normal date (July 18, 2013
) from time-stamp and avoid the deprecated methods ?