如何在Android中获取迪拜的当前日期和时间?

时间:2013-06-23 07:04:21

标签: android datetime

我正在获取该设备的当前日期,但我想要迪拜市的日期和时间,任何人请帮助我这样做。当显示活动时,应显示日期和时间,  任何帮助都会得到满足。谢谢..

2 个答案:

答案 0 :(得分:2)

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parsed = format.parse("2011-03-01 15:10:37");
// => This time is in the user phone timezone, you will maybe need to turn it in UTC!
TimeZone tz = TimeZone.getTimeZone("Asia/Dubai");
format.setTimeZone(tz);

String result = format.format(parsed);

答案 1 :(得分:0)

您可以使用TimeZone传递给SimpleDateFormat

     SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
      sdf.setTimeZone(TimeZone.getTimeZone("Asia/Dubai"));
相关问题