我有两个变量.weekStartDate和startDate.它们都基本上保持相同的时间戳:
this.startDate Date {Mon Mar 26 2012 00:00:00 GMT+0530 (IST)}
this.weekStartDate Date {Mon Mar 26 2012 00:00:00 GMT+0530 (IST)}
Run Code Online (Sandbox Code Playgroud)
问题是:当我尝试getTime()时,它们显示的值略有不同:
this.startDate.getTime() 1332700200000
this.weekStartDate.getTime() 1332700200506
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
差异是506毫秒.当你打电话不显示的毫秒数toString()一的Date对象,所以,除非你比较的数值什么比秒更精确的将被忽视.
要重置毫秒0,请使用:
this.weekStartDate.setMilliseconds(0);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1577 次 |
| 最近记录: |