Hi all

I have discovered a problem with getting correct DST saving value,
.
TimeZone.getDSTSavings() normally returns 3600000 (1 hour), but should
for timezone ID "Australia/Lord_Howe" return 1800000 (30 minutes).
(See http://www.timeanddate.com/worldclock/clockchange.html?n=750)

I believe that GregorianCalendar uses TimeZone.getDSTSavings(), but
that is only my guess from looking at the source at
http://www.java2s.com/Open-Source/Android/android-core/platform-libcore/java/util/GregorianCalendar.java.htm

Now, if I instead of using TimeZone.getDSTSavings() looks att what
GregorianCalendar.get(Calendar.DST_OFFSET) returns, it is infact
1800000 when DST is on, which the following App reveals:

package x.getdstavingsissue;
/*
 * Result on Android 2.2 is:
 *      TimeZone.getDSTSavings() == 3600000
 *      GregorianCalendar DST_OFFSET == 1800000
 */
import java.util.Calendar;
import java.util.TimeZone;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class GetDSTSavingsIssueActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Calendar cal =
Calendar.getInstance(TimeZone.getTimeZone("Australia/Lord_Howe"));
        int getdstsavings = cal.getTimeZone().getDSTSavings();
        cal.set(2012, 1, 1, 0, 0, 0);
        cal.set(Calendar.MILLISECOND, 0);
        int caldstsavings = cal.get(Calendar.DST_OFFSET);
                ((TextView) findViewById(R.id.getdstsavings))
                .setText("TimeZone.getDSTSavings() == " +
String.valueOf(getdstsavings));
                ((TextView) findViewById(R.id.caldstsavings))
                .setText("GregorianCalendar DST_OFFSET == " +
String.valueOf(caldstsavings));
                Log.d("GetDSTSavingsIssue", "TimeZone.getDSTSavings() == " +
String.valueOf(getdstsavings));
                Log.d("GetDSTSavingsIssue", "GregorianCalendar DST_OFFSET == " +
String.valueOf(caldstsavings));
   }
}

I tried running on 2.2 in emulator and on a device, and also on 3.2 in
emulator. Same result.

So, I wonder how this can be.

Regards
Jan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to