OK, I found a simple solution here,
To get the UTC TimeZone of the phone device sets you will need the
codes below:
// retrieve the time information from the system and parse into a Time
object
Time mSavedTime = new Time();
long now = System.currentTimeMillis();
mSavedTime.set(now);
// parse the timezone information from the Time object
TimeZone mMyTimeZone = TimeZone.getTimeZone(mSavedTime.timezone);
// transfer the long TimeZone offset into hours unit
int utc_bias = (mMyTimeZone.getRawOffset() / 3600000);
// take daylight saving into consideration, however we need the time
for now. The year, month and day could get from the Time object
Calendar mCal = Calendar.getInstance(mMyTimeZone);
mCal.set(/* year */, /* month, notice that starts from 0 to 11 */, /*
day */);
if(mMyTimeZone.useDaylightTime() && mMyTimeZone.inDaylightTime
(mCal.getTime()))
{
utc = utc + (mMyTimeZone.getDSTSavings() / 3600000);
}
On 2月19日, 下午3時14分, bw <[email protected]> wrote:
> I also couldn't find the solution..
>
> A lookup table/database workaround is posted
> here:http://groups.google.com/group/android-developers/browse_thread/threa...
>
> On Jan 22, 9:59 pm, yukinoba <[email protected]> wrote:
>
> > to dear all Android developers,
>
> > I need to know theUTCbias of my phone to correct theUTCtime
> > information I got from a site. I have read earlier posts and already
> > found the solution to get TimeZone information from the
> > "System.currentTimeMillis();" method. However, I need to translate the
> > TimeZone (as like, "Asia/Taipei") to theUTCbias that it has to be
> > (as like, "UTC+8" or other formats).
>
> > Does anyone know the actual API solution? I have surveyed
> > android.util.TimeUtils and found nothing to do this.
>
> > The worst solution may I have is to build a "TimeZone/UTC" database
> > table to translate this...
>
> > Best regards,
> > Nicholas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---