Converting Timestamp as String to Date in android

android, timestamp

Solution

Just use the Time class. Try something similar to this.

Time time = new Time();
time.set(Long.valueOf(yourTimeString));

If you really need a Date object just try this.

Date date = new Date(Long.parse(yourTimeString));

Problem

I am getting Timestamp value as 1291204449 from server so I extracted the value by implementing handler. Now I want to convert timestamp value to date.(But the problem is in my activity I stored this value in a string variable because handler returning in string format).

Original source