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

前端 未结 10 926
既然无缘
既然无缘 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:49

    When incrementing time you should convert back to UTC and then add or subtract. Use the local time only for display.

    This way you will be able to walk through any periods where hours or minutes happen twice.

    If you converted to UTC, add each second, and convert to local time for display. You would go through 11:54:08 p.m. LMT - 11:59:59 p.m. LMT and then 11:54:08 p.m. CST - 11:59:59 p.m. CST.

提交回复
热议问题