TimeZone.java (getOffset): New method.
authorMichael Koch <konqueror@gmx.de>
Thu, 18 Dec 2003 16:43:02 +0000 (16:43 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Thu, 18 Dec 2003 16:43:02 +0000 (16:43 +0000)
2003-12-18  Michael Koch  <konqueror@gmx.de>

* java/util/TimeZone.java (getOffset): New method.

From-SVN: r74784

libjava/ChangeLog
libjava/java/util/TimeZone.java

index b384a2939986258265d62ab68a9f46c7ada717ad..36048e4bf2a083d1d864551fc79447154e152412 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-18  Michael Koch  <konqueror@gmx.de>
+
+       * java/util/TimeZone.java (getOffset): New method.
+
 2003-12-17  Fernando Nasser  <fnasser@redhat.com>
  
        * gnu/java/awt/peer/gtk/GtkListPeer.java (handleEvent): Fix generation
index db9ff6b1051a1fbbb01d3456876f65a2d1e9e60f..2636956527df0b70202c856f27a1ae7ea8db8f91 100644 (file)
@@ -1,5 +1,6 @@
 /* java.util.TimeZone
-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+   Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -809,6 +810,21 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
   public abstract int getOffset(int era, int year, int month,
                                int day, int dayOfWeek, int milliseconds);
 
+  /**
+   * Get the time zone offset for the specified date, modified in case of
+   * daylight savings.  This is the offset to add to UTC to get the local
+   * time.
+   * @param date the date represented in millisecends
+   * since January 1, 1970 00:00:00 GMT.
+   * @since 1.4
+   */
+  public int getOffset(long date)
+  {
+    return (inDaylightTime(new Date(date))
+            ? getRawOffset() + getDSTSavings()
+            : getRawOffset());
+  }
+  
   /**
    * Gets the time zone offset, ignoring daylight savings.  This is
    * the offset to add to UTC to get the local time.