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
Comments
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 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. |
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 |
CL https://golang.org/cl/10299 mentions this issue. |
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>
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>
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]
The text was updated successfully, but these errors were encountered: