Do I using GregorianCalendar in the right way?

by Wang He » Fri, 06 Mar 2009 18:00:00 GMT


Sponsored Links
 0. I setup my Android emulator time zone to: Australia/Adelaide GMT
+10:30
1. My code snippet:

        mtz = new SimpleTimeZone(8 * 60 * 60 * 1000, "Asia/Shanghai");
        GregorianCalendar gc1 = new GregorianCalendar(); //using default,
that is Adelaide
        GregorianCalendar gc2 = new GregorianCalendar(mtz); //using my
customized time zone

        Date d1 = gc1.getTime();
        Log.v(TAG, "testCalendar2: d1.toString: "+d1.toString());
        Log.v(TAG, "testCalendar2: d1.toGMTString: "+d1.toGMTString());

        Date d2 = gc2.getTime();
        Log.v(TAG, "testCalendar2: d2.toString: "+d2.toString());
        Log.v(TAG, "testCalendar2: d2.toGMTString: "+d2.toGMTString());

2. My Log.v
20:11:04.807: VERBOSE/worldclock(669): testCalendar2: d1.toString: Fri
Mar 06 20:10:55 GMT+10:30 2009
20:11:04.927: VERBOSE/worldclock(669): testCalendar2: d1.toGMTString:
6 Mar 2009 09:40:55 GMT
20:11:13.967: VERBOSE/worldclock(669): testCalendar2: d2.toString: Fri
Mar 06 20:10:55 GMT+10:30 2009
20:11:14.277: VERBOSE/worldclock(669): testCalendar2: d2.toGMTString:
6 Mar 2009 09:40:55 GMT

3. I supposed to think d2 should be the Asia/Shanghai datetime, but
GregorianCalendar.getTime always returns the default time zone based
datetime. So:

Do I using the GregorianCalendar in the right way?
Why will GregorianCalendar provides a timezone based constructor?

BRs
He

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Development for XOOM?

Should I use the XOOM skin or just create an AVD with Android 3.0 in
the SDK? What's the advantage of using the XOOM skin?

Thanks!

-- 

2. Out of memory issue in Android

Hi,
I am using the byte array for storing the image. I want to store image
in binary format back to file. While calculating the length of byte
array, i am getting the Out of memory issue.
So please help me to overcome this problem.

Thanks in advance...

Thanks and Regards,
Rohit D

-- 

3. lockNow() doesnot work as expected on LG ally and Droid X which are verizon devices

4. acess google calendar to retrieve events specific to a date

5. UnknownHostException

6. new to android..............

7. Mount USB pendriveto simulate SD Card functionality