Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: time.Local doesn't match the timezone reported from Java on android #10857

Closed
eliasnaur opened this issue May 14, 2015 · 4 comments
Closed
Milestone

Comments

@eliasnaur
Copy link
Contributor

Java and Go should have matching default timezones.

log.Println("local: ", time.Local)

prints

local: UTC

while

Log.i(TAG, "java timezone: " + java.util.TimeZone.getDefault());

prints

java timezone: libcore.util.ZoneInfo[id="Pacific/Midway",mRawOffset=-39600000,mEarliestRawOffset=-39600000,mUseDst=false,mDstSavings=3600000,transitions=4]

@hyangah hyangah changed the title x/mobile/cmd/gomobile: time.Local don't match the java timezone time: time.Local doesn't match the timezone reported from Java on android May 14, 2015
@hyangah
Copy link
Contributor

hyangah commented May 14, 2015

It seems we need to look for the zoneinfo timezone db and index files in other directories on android. e.g. /system/usr/share/zoneinfo?

@hyangah hyangah added this to the Go1.5 milestone May 14, 2015
@ianlancetaylor
Copy link
Contributor

@hyangah you may also have a zoneinfo problem, but the problem with time.Local is most likely different. If the TZ environment variable is not set, the time package loads /etc/localtime. On conventional Unix systems that is a copy of the zoneinfo data for the local timezone. On Android that file may be somewhere else, or it may not exist.

See initLocal in time/zoneinfo_unix.go.

@rakyll
Copy link
Contributor

rakyll commented May 15, 2015

On Android, there is no /etc/localtime. The contents of /system/usr/share/zoneinfo is not similar to the other unixes, and TZ env var is not set.

All I was able to do was getprop persist.sys.timezone.

@gopherbot
Copy link

CL https://golang.org/cl/10299 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
This trusts bionic's reading of the system clock.

Future work should address the fact we cannot read the Android
zoneinfo file.

Fixes golang/go#10857.

Change-Id: I5a684fecc920dce5ab8f624658e91d9e2d71738d
Reviewed-on: https://go-review.googlesource.com/10299
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
This trusts bionic's reading of the system clock.

Future work should address the fact we cannot read the Android
zoneinfo file.

Fixes golang/go#10857.

Change-Id: I5a684fecc920dce5ab8f624658e91d9e2d71738d
Reviewed-on: https://go-review.googlesource.com/10299
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants