我正在尝试这样做 1.获取我的时间当前时间和时区。 2. 我从谷歌知道那个特定国家的时区。 3.计算时区差异。 4. 从当前时间减去这个差值。这将给我时间在其他国家。 我卡在了第 3 步和第 4 步。 我得到这样的当前时间
Date d = new Date();
CharSequence s = DateFormat.format("hh:mm:ss", d.getTime());
和这样的时区
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"),
Locale.getDefault());
Date currentLocalTime = calendar.getTime();
SimpleDateFormat date = new SimpleDateFormat("Z");
String localTime = date.format(currentLocalTime);
让特定国家/地区的时区由字符串 x 表示。现在我如何获取 localTime - x 然后是 currentTime - (localTime - x)。
最佳答案
x 是时区 ID,有一个列表的链接。只需要向 gettimeZone("with the time zone id") 提供您想知道时间的城市的时区(我说城市是因为有些国家/地区有很多时区,例如美国或俄罗斯)。
TimeZone tz = TimeZone.getTimeZone("x")
http://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/
关于java - 如果我在不同的国家/地区,我如何知道特定国家/地区的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24093414/