• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ZONE_OFFSET and DST_OFFSET

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am using Calendar.ZONE_OFFSET and Calendar.DST_OFFSET

Can anyone please tell me the exact use of these in regards of Calendar?

Thanks
Regards
Rajesh
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you look at the Calendar API JavaDoc for these constants, it explains that these values are used as values for the 'field' parameter for the Calendar's set(int field, int value) and get(int field) methods. For example, in the following code, I use the Calendar.ZONE_OFFSET to determine the Greenwich Mean Time (GMT) offset for my computer.



Note that the TimeUnit Enum I use was added in Java 5, and the HOURS was added to that Enum in Java 6. For older versions of Java, you can just do the math yourself.

So basically, these values (along with others in the Calendar class) tell the get and set method what field of the calendar you want the operation to occur on.

In the case of the the GMT offset, I could have done this in a different way:


[ November 11, 2008: Message edited by: Mark Vedder ]
 
Rajesh Kumar Hari
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark..
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic