【发布时间】:2015-09-24 22:29:18
【问题描述】:
Android 本地时间到美国东部时间的转换
代码:
SimpleDateFormat serverDateFormat=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
serverDateFormat.setTimeZone(TimeZone.getTimeZone("EST"));
Calendar calender= Calendar.getInstance(Locale.getDefault());
String time=serverDateFormat.format(calender.getTime());
但我得到了错误的时间。 与正确时间相差一小时。 例如: 当地时间:2015 年 7 月 7 日星期二 17:30:00 GMT+05:30 形成时间:2015/07/07 07:00:00 正确时间:2015/07/07 08:00:00
【问题讨论】:
标签: android date timezone simpledateformat