On Tue, Jan 24, 2012 at 12:02 PM, Jan Skarvall <[email protected]> wrote: > I just reported it, se http://code.google.com/p/android/issues/detail?id=24684
Cool, I'll keep an eye on it. I really feel like adding a joke here about Lord Howe needing a watch that kept better time and wasn't always off by a half-hour, but I'll just keep my mouth shut. Oh, wait, I typed that already -- better delete it before I press Se... > > Jan > > On Jan 24, 5:33 pm, Jan Skarvall <[email protected]> wrote: >> Thanks! >> >> I forgot to include main.xml. >> >> You may either remove the lines: >> >> ((TextView) findViewById(R.id.getdstsavings)) >> .setText("TimeZone.getDSTSavings() == " + >> String.valueOf(getdstsavings)); >> ((TextView) findViewById(R.id.caldstsavings)) >> .setText("GregorianCalendar DST_OFFSET == " + >> String.valueOf(caldstsavings)); >> >> or change res/layout/main.xml to look like below: >> >> <?xml version="1.0" encoding="utf-8"?> >> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ >> android" >> android:layout_width="fill_parent" >> android:layout_height="fill_parent" >> android:orientation="vertical" > >> <TextView >> android:id="@+id/getdstsavings" >> android:layout_width="fill_parent" >> android:layout_height="wrap_content"/> >> <TextView >> android:id="@+id/caldstsavings" >> android:layout_width="fill_parent" >> android:layout_height="wrap_content"/> >> </LinearLayout> >> >> Also, the line: >> >> cal.set(Calendar.MILLISECOND, 0); >> >> can be deleted. It is irrelevant for the result. >> >> Jan >> >> On Jan 24, 1:13 pm, Mark Murphy <[email protected]> wrote: >> >> >> >> >> >> >> >> > I know some tricks are played with the time zone database, compared to >> > regular Java environments, simply for performance issues. It used to >> > be the first time you used something that touched time zones that your >> > app would freeze for a full second while the database was loaded. Now, >> > they pre-load the time zone database in zygote and share it among all >> > VMs. It's possible that there's a bug introduced in that process. >> >> > I would file an issue on this at b.android.com, with a complete >> > project containing your source code that demonstrates the error. >> >> > On Tue, Jan 24, 2012 at 6:18 AM, Jan Skarvall <[email protected]> >> > wrote: >> > > 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). >> > > (Seehttp://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-libco... >> >> > > 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 >> >> > -- >> > Mark Murphy (a Commons >> > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy >> >> > Android Training in DC:http://marakana.com/training/android/ > > -- > 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 -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in DC: http://marakana.com/training/android/ -- 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

