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. Broken Gallery View? using Gallery.setSelection(int position, boolean animate)

setSelection() is not meant to be animated.






-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

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

2. Broken Gallery View? using Gallery.setSelection(int position, boolean animate)

I'm trying to set the selection of a Gallery in code. I would like to
have the Gallery smoothly roll down a few items over the duration of a
second or two. At frist glance, it appears that two members would to
the trick:

Gallery.setAnimationDuration(int animationDurationMillis);
Gallery.setSelection(int position, boolean animate);

It turns out that the setAnimationDuration only seems to affect the
{*filter*}-bandy "return-to-center" effect of the Gallery. In other words,
when a gallery comes to rest after a fling, and a gallery item is off
center, the animationDurationMillis is used to control the duration of
the Gallery centering up the item. However, the value seems to have no
effect on the setSelection. No matter what value is set with
setAnimationDuration, the Gallery seems to render about 2 or 3 frames
when flying between items 1 and 10 for example.

Is this working as designed? Does anyone know a trick or workaround
that would let me properly animate setSelection? I'd be especially
grateful if we could do it with an "Ease Out" effect.
--~--~---------~--~----~------------~-------~--~----~

3. Run two android instances on the same host and comunicate betwen them using socket

4. How to remove a contact with a specified phone number?

5. Install wlan asus eee

6. Dutch citizen cannot install Dutch localized app

7. RC33 Available for Download