JDK-4300378 : API: SimpleTimeZone: getDSTSavings() is returning improper value.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_7
  • CPU: generic,sparc
  • Submitted: 1999-12-17
  • Updated: 2001-01-05
  • Resolved: 2000-12-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Even though a time zone does not observe DST, "getDSTSavings()" is returning a non-zero value.

After discussing further with other I18N SQE, it was felt that this can be confusing to a user. Though the user does have "useDaylightTime()" to figure out whether the time zone observes DST, having "getDSTSavings()" return a contradicting value is inconsistent.

Here's a quick program to demonstrate this:

----------------------------- Cut Here --------------------------

import java.util.*;

public class GetDSTSavingsTest {

    SimpleTimeZone stz;

    public GetDSTSavingsTest() {
        stz = (SimpleTimeZone)TimeZone.getTimeZone("Asia/Tokyo");

        System.out.println("Observes daylight savings time? " +
                           stz.useDaylightTime());
        System.out.println("Daylight savings time value(should be 0 if not " +
                           "observed): " + stz.getDSTSavings());
    }

    public static void main(String[] args) {
        new GetDSTSavingsTest();
    }
}

----------------------------- Cut Here --------------------------

edmund.lou@eng 1999-12-17

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin FIXED IN: merlin-beta INTEGRATED IN: merlin-beta VERIFIED IN: merlin-beta
14-06-2004

SUGGESTED FIX CCC proposal: 4300378: API: SimpleTimeZone: getDSTSavings() is returning improper value. Release: Merlin Problem: SimpleTimeZone.getDSTSavings() always returns a non-zero value even the time zone doesn't observe daylight saving time. This behavior is because the method is expected to be called only when the useDaylightTime() value is true. However, this behavior is not documented and confusing to developers. It should return 0 if the time zone doesn't observe daylight saving time. Requesters: Masayoshi Okutsu RFE/BUG: 4300378: API: SimpleTimeZone: getDSTSavings() is returning improper value. Proposed Solution and API Change: The following API change is proposed. * Change the current API: public int getDSTSavings() Returns the amount of time in ms that the clock is advanced during DST. Returns: the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. A positive number, typically one hour (3600000). Since: 1.2 to: public int getDSTSavings() Returns the amount of time in milliseconds that the clock is advanced during Daylight Saving Time. Returns: the number of milliseconds the time is advanced with respect to standard time when the daylight saving rules are in effect, or 0 (zero) if this time zone doesn't observe Daylight Saving Time. Since: 1.2 Note: this method has been promoted to its super class, TimeZone, as a part of the CCC request for "4268105: RFE: Request for a new method: TimeZone.getOffset(Date)" which has been approved by CCC. That method already specifies the proposed behavior. API Reviewed and approved by: Norbert Lindenberg Implementation: - Engineer who made (or will make) the changes: Masayoshi Okutsu - Date at which changes will be complete: 11/17/00 - Number of lines of new or modified code: + Java: 4 (excluding comment lines) + Native: 0 - Code reviewed (or will be reviewed) by: Yuka Kamiya Risk assessment: very low This API change is very unlikely to affect existing applications which are supposed to check the useDaylightTime() value before calling. The implementation change is very simple. The API change is considered as very low risk. SQE (product testing) impact: QA test items have to be modified to accommodate this behavior change. Approved by Bae-Chul Kim. JCK (compatibility testing) impact: JCK test items, if any, have to be modified to accommodate this behavior change. Approved by Dmitri A. Silaev. Doc impact: The documentation for the API change above is considered sufficient. Approved by Alan Sommerer. Localization impact: None Internationalization impact: None Security impact: None Legal impact: None For feature changes, Product Marketing approval: N/A masayoshi.okutsu@Eng 2001-01-09
09-01-2001

PUBLIC COMMENTS Verified in Merlin-beta b46 edmund.lou@eng 2001-01-05
05-01-2001

EVALUATION The method should return 0 for a time zone where no DST is observed. The API needs to clarify this behavior. masayoshi.okutsu@Eng 1999-12-20 The API doc specifies that this method returns a positive number. This has to be changed. masayoshi.okutsu@Eng 2000-03-27 As a part of other time zone related enhancements for Merlin, SimpleTimeZone.getDSTSavings() will be promoted to its superclass, TimeZone, with the correction requested by this bug report. The API spec of SimpleTimeZone.getDSTSavings() itself still needs a correction. masayoshi.okutsu@Eng 2000-10-26 The API was changed as proposed in Suggested Fix. masayoshi.okutsu@Eng 2001-01-09
26-10-2000