Java: Timezone why different timezone give same value in millisec

前端 未结 3 1672
清歌不尽
清歌不尽 2020-12-03 15:05

I have following code, my target is going to return GMT+0 time in millisec. But Why I always get my local timezone millisec?

Calendar cal         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 15:29

    getTimeInMillis() method return the current time as UTC milliseconds from the epoch. So, you are getting same milliseconds even both calendar object has different timezone.

提交回复
热议问题