Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Timezone in java?

  • 27-05-2005 1:28pm
    #1
    Closed Accounts Posts: 2,653 ✭✭✭


    Is there a method in java to get the timezone that a computer is in? All I want is a method that checks the system settings and returns an integer, from -12 to +12 for whatever the difference is to GMT. I've been looking at the java Timzeone API but it only seems to support creating timezones based on inputted locations, I want something that just automatically checks what location the computer is in...


Comments

  • Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭daymobrew


    I know shag all Java, but from looking at the online docs maybe the TimeZone class could be useful (TimeZone.getDefault() method).

    Or the Calendar class.
    The Date class had the following note for the getTimezoneOffset() method:
    int getTimezoneOffset()
    Deprecated. As of JDK version 1.1, replaced by -(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000).
    so maybe ZONE_OFFSET and DST_OFFSET of the Calendar class is what you need.


  • Closed Accounts Posts: 2,653 ✭✭✭steviec


    Yea got it... I just wasnt reading the API properly... timezone.getdefault() does the trick :)


Advertisement