使用Android格式化字符串时间戳 [英] Formatting a string timestamp with Android

查看:88
本文介绍了使用Android格式化字符串时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,这使我把头发扯了.

For some reason this has me tearing my hair out.

我有一个UNIX时间戳作为Android中的字符串.我要做的就是格式化此格式,以便它返回用户droid时区中的日期/时间.

I have a UNIX timestamp as a string in Android. All I want to do is format this so that it returns the date/time in the user's droid time zone.

我可以将其转换为时间戳,但是它使用GMT而不是其本地区域.

I can convert it to a timestamp just fine, but it uses GMT rather than their localised zone.

谢谢

推荐答案

SimpleDateFormat 构造函数与所需的 Locale 一起使用:

Use the SimpleDateFormat constructor with the Locale you need:

输出:

1299002115000
Tue Mar 01 12:55:15 EST 2011

这篇关于使用Android格式化字符串时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆