【发布时间】:2023-03-12 15:15:02
【问题描述】:
我想用 java 获取以色列的当前时间,这是我的代码:
TimeZone timeZone = TimeZone.getTimeZone("Israel");
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(timeZone);
DateFormat timeFormat = new SimpleDateFormat("HH:mm");
String curTime=timeFormat.format(calendar.getTime());
但它总是给我带来比以色列当前时间少 7 小时的时间,有人知道如何达到以色列当前时间吗?
【问题讨论】:
-
尝试只使用
new Date()。 -
我现在试过了,但它不起作用,也许我做的不好,你能发布修复我原始代码的代码吗?
-
TimeZones in Java的可能重复