Java: Calculating time zone difference

后端 未结 5 830
野的像风
野的像风 2021-02-07 19:07

How do I get the time difference from GMT for a specific date and time zone in Java?

Determining whether a specific time zone is in DST is quite straight-forward:

<
5条回答
  •  臣服心动
    2021-02-07 19:50

    I see this is an old thread - but adding this since I had a similar requirement recently - This gives the actual difference in millis based on the CURRENT time(millis from epoch).

        TimeZone.getTimeZone("America/New_York").getOffset(Calendar.getInstance().getTimeInMillis())
    

提交回复
热议问题