Error updating tzdata 2018f (Released 2018-10-18) with tzupdater-2.2.0

前端 未结 8 885
既然无缘
既然无缘 2020-12-03 07:40

I\'m trying to update JVM\'s Time Zone info using TZUpdater 2.2.0.

> [root@local tzupdater-2.2.0]# java -jar tzupdater.jar -V
  tzupdater version 2.2.0-b0         


        
相关标签:
8条回答
  • 2020-12-03 08:22

    Yes, the rules for Japan in 1948-1951 changed in 2018f in an "interesting" way: officially, Japan's fall back occurred at 25:00 on Saturday, instead of 01:00 on the Sunday. That confused the Java time zone updater, as well as my own Noda Time project.

    There's now a commit to avoid 25:00 in the "rearguard" format - the rearguard format is basically more conservative, avoiding things like Ireland's negative DST.

    I would expect a 2018g release at some point reasonably soon, to include that fix. Assuming the tzupdater tool uses the rearguard appropriately, I'd expect that to sort things out. If you can possibly wait until then, I'd do so. Otherwise, use the -l flag on tzupdater to specify a different data source, e.g. for 2018e: https://data.iana.org/time-zones/releases/tzdata2018e.tar.gz

    0 讨论(0)
  • 2020-12-03 08:22

    If you need to use version 2018f but not the Asia timezone you can use it from 2018e and the other files from 2018f.

    I've created the file tzdata2018f-01.tar.gz in my repository https://github.com/lucasbasquerotto/my-projects/tree/master/tz for anyone that wants to avoid making these manual changes.

    There is an example of using ziupdater when creating a docker image with OpenJDK, but if you use Oracle JDK you should be able to use almost the same code to use tzupdater changing

    java -jar /app/tmp/ziupdater-1.0.1.2.jar -l file:///app/tmp/tzdata2018f-01.tar.gz
    

    to

    java -jar /app/tmp/tzupdater.jar -l file:///app/tmp/tzdata2018f-01.tar.gz
    

    or even

    java -jar tzupdater.jar -l https://github.com/lucasbasquerotto/my-projects/raw/master/tz/tzdata2018f-01.tar.gz
    

    if you don't want to download it manually.

    In the example in my repository it generates a Docker image, but you can use it without docker, with Java installed directly in your OS.

    I executed the last example above on my local machine (that uses Oracle JDK) and the timezone was corrected successfully:

    public static void main(String[] args) {        
        System.out.println("Date: " + new Date()); // prints correctly now
    }
    

    Just make sure that you aren't using some third-party library (like Joda Time) that uses timezone data hardcoded in its own jar (or generate a jar from the source with updated timezone data, like in https://www.joda.org/joda-time/tz_update.html).

    0 讨论(0)
提交回复
热议问题