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. Open core changeset between eclair and froyo

Hi,

I wanted to know the changeset between froyo & eclair,Donut in open
core module.
please help me in getting the detailed changeset,
I wanted to know the details like what are the new features added in
new version of android...

regards,

Bala Abiraman

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. How to increase Output buffer size for MPEG-4 video decoder in Opencore in Android

That looks approporiate for UseBuffer mode.,








> > > website:

3. Can we access windows partition through android?

4. How to change output from file to stream over internet

5. Can't kill the running process when exception through

6. How to use customview with home screen ?

7. Setting up VPN