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

Comments

Projects
None yet
6 participants
@eliasnaur
Copy link
Contributor

commented May 14, 2015

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented May 15, 2015

@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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

commented May 21, 2015

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

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.