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

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

    Instead of converting each date, you can use the following code:

    long difference = (sDt4.getTime() - sDt3.getTime()) / 1000;
    System.out.println(difference);
    

    And then see that the result is:

    1
    

提交回复
热议问题