Java get current time in Israel

I am tring to get the current time in Israel in java this is my code:

TimeZone timeZone = TimeZone.getTimeZone("Israel");
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(timeZone);

DateFormat timeFormat = new SimpleDateFormat("HH:mm");
String curTime=timeFormat.format(calendar.getTime());

but it is always bring me 7 hours less from the current time in Israel someone have idea how to achieve the current time in Israel?

Jon Skeet
people
quotationmark

You're setting the time zone in your calendar, but you should be setting it in your DateFormat. Additionally, you should be using Asia/Jerusalem as the time zone name. You don't need a Calendar at all - just new Date() gives the current instant:

DateFormat timeFormat = new SimpleDateFormat("HH:mm");
timeFormat.setTimeZone(TimeZone.getTimeZone("Asia/Jerusalem"));
String curTime = timeFormat.format(new Date());

You should note that the time zone in Jerusalem is particularly hard to predict (it fluctuates a lot) so if the time zone data source that your JVM uses is out of date, it may be inaccurate.

people

See more on this question at Stackoverflow