Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Time Zone Query

 
Pratik Parekh
Greenhorn
Posts: 21
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the meaning of this code

Long timeStampSecs=System.currentTimeMillis();
long millis=timeStampSecs*1000L-TimeZone.getTimeZone(DateConstants.TZ_IST).getRawOffset();

 
Claudiu Chelemen
Ranch Hand
Posts: 75
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you multiply the milliseconds returned by System.currentTimeMillis() by 1000, you would get the current time in microseconds.
Subtracting milliseconds returned by the getRawOffset() method from the current time in microseconds, I'm pretty sure that the result is irrelevant.

I believe that whoever wrote this was trying to get UTC time in millis, even so, the use of a Calendar would have been more appropiate.

Claudiu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic