需要在GMT中显示时间......但它以UTC显示
long m=Long.parseLong("1444588200000");
Date localTime = new Date(m);
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"),
Locale.getDefault());
DateFormat date = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
String time = date.format(localTime);
infoip.setText(" "+time);
答案 0 :(得分:0)
试试这个,
final Date currentTime = new Date();
final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS");
// Give it to me in GMT time.
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println("GMT time: " + sdf.format(currentTime));
答案 1 :(得分:0)
尝试这样的希望工作。
Calendar cal = Calendar.getInstance();
// setting the timezone for which you want
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.setTimeInMillis();
// The date is in your home timezone
Date date = cal.getTime();
TimeZone tz = TimeZone.getTimeZone("GMT");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS", Locale.GMT);
sdf.setTimeZone(tz);
// Then we do the conversion to convert the date you provided in milliseconds to the GMT timezone
String result = sdf.parse(date);