在android中将时间戳作为字符串转换为日期

use*_*046 10 android timestamp

我从服务器获取时间戳值为1291204449所以我通过实现处理程序提取值.

现在我想将timestamp值转换为date.(但问题出在我的活动中,我将此值存储在字符串变量中,因为处理程序以字符串格式返回).

Oct*_*ean 9

只需使用Time类.尝试类似的东西.

Time time = new Time();
time.set(Long.valueOf(yourTimeString));
Run Code Online (Sandbox Code Playgroud)

如果你真的需要Date对象,试试这个.

Date date = new Date(Long.parse(yourTimeString));
Run Code Online (Sandbox Code Playgroud)