我使用这两种方法将本地时间转换为GMT / UTC,反之亦然,这对我来说没有任何问题。
public static Date localToGMT() { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); Date gmt = new Date(sdf.format(date)); return gmt;}将要转换为设备本地时间的GMT / UTC日期传递给此方法:
public static Date gmttoLocalDate(Date date) { String timeZone = Calendar.getInstance().getTimeZone().getID(); Date local = new Date(date.getTime() + TimeZone.getTimeZone(timeZone).getOffset(date.getTime())); return local}


