Why is subtracting these two times (in 1927) giving a strange result?

前端 未结 10 929
既然无缘
既然无缘 2020-11-21 08:10

If I run the following program, which parses two date strings referencing times 1 second apart and compares them:

public static void main(String[] args) throw         


        
10条回答
  •  野的像风
    2020-11-21 08:35

    IMHO the pervasive, implicit localization in Java is its single largest design flaw. It may be intended for user interfaces, but frankly, who really uses Java for user interfaces today except for some IDEs where you can basically ignore localization because programmers aren't exactly the target audience for it. You can fix it (especially on Linux servers) by:

    • export LC_ALL=C TZ=UTC
    • set your system clock to UTC
    • never use localized implementations unless absolutely necessary (ie for display only)

    To the Java Community Process members I recommend:

    • make localized methods, not the default, but require the user to explicitly request localization.
    • use UTF-8/UTC as the FIXED default instead because that's simply the default today. There is no reason to do something else, except if you want to produce threads like this.

    I mean, come on, aren't global static variables an anti-OO pattern? Nothing else is those pervasive defaults given by some rudimentary environment variables.......

提交回复
热议问题