This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes ZONE_OFFSET and DST_OFFSET Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ZONE_OFFSET and DST_OFFSET" Watch "ZONE_OFFSET and DST_OFFSET" New topic
Author

ZONE_OFFSET and DST_OFFSET

Rajesh Kumar Hari
Greenhorn

Joined: Oct 07, 2008
Posts: 6
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
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

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

Joined: Oct 07, 2008
Posts: 6
Thanks Mark..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ZONE_OFFSET and DST_OFFSET
 
Similar Threads
Dice Question
Best way of learning EJB and EJB-QL!
Passed 287 with 85%...now ICED!
Passed the IBM-141
Need Explanation