Java TimeZone getOffset() Example

TimeZone class getOffset() method example. This example shows you how to use getOffset() method.


Syntax is : public int getOffset(long date)
Method returns the offset of this time zone from UTC at the specified date. If Daylight Saving Time is in effect at the specified date, the offset value is adjusted with the amount of daylight saving.

Here is the code.
/**
 * @(#) GetOffsetTimeZone.java
 * A class representing use of method getOffset() of TimeZone
 class in java.util Package.
 * @Version  27-May-2008
 @author   Rose India Team
 */
import java.util.*;

class GetOffsetTimeZone {
    public static void mainString args[] ){
        // Create object of TimeZone class. 
        TimeZone obj = TimeZone.getTimeZone("Europe/Paris");
        // getOffset(long date) method call for specified time zone.
      int offset = obj.getOffset(Calendar.ZONE_OFFSET);
        System.out.println("Offset of this time zone is : " + offset);
  }
}

Output of the program.
Offset of this time zone is : 3600000

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US