标签:android
在有些软件中,可能需要展示一些时间信息,而这些信息可能是Server以UTC格式或Unix timestamp 格式推送过来的,终端可能需要将这些转换为本地时间展示。
终端的制式可能是12小时制、也可能是24小时制的
今天就遇到将utc时间格式转换为GMT
HH:返回的是24小时制的时间
hh:返回的是12小时制的时间
下面就是转换的类型代码,当然服务器的格式 2013-06-13T14:15:44.000
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd‘T‘HH:mm:ss.SSS");
根据服务器格式修改成对应的就好。
srcTime就是上面传的2013-06-13T14:15:44.000字符串,timezone 就是你自己想转换的时区,比如我转换北京东八区,TimeZone.getTimeZone("GMT+8")这样就转换成功了非常方便。
版权声明:本文为博主原创文章,未经博主允许不得转载。
Android 转换UTC时间:2013-06-13T14:15:44.000的时间格式 为GMT时间
标签:android
原文地址:http://blog.csdn.net/chenaini119/article/details/46771615