localtime() is returning GMT time instead of local time

557 views
Skip to first unread message

Cacau

unread,
Aug 11, 2011, 6:40:06 PM8/11/11
to andro...@googlegroups.com
Hi,

I have code that calls localtime() on android. On Android , it returns the gmt time instead of local. The exactly same code returns the localtime on Linux or CYGWIN.

Any ideas?

Thanks!

Luiz

Stephen Williams

unread,
Aug 11, 2011, 7:03:36 PM8/11/11
to andro...@googlegroups.com
You might want to post code.  Be sure that you are actually printing unconverted time.  You can sometimes have GMT time, but have it translated to the local timezone when printing because the timezone wasn't configured to be GMT for the formatter.

I found Java / Android date parsing to be lacking here too.  Some standard ISO and IETF time formats, which in some cases can validly have 'Z' for a time zone, are not directly parseable without editing the string (like "z"->"+000").

sdw

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/J1bR5lcKEKwJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.



--
--
Stephen D. Williams s...@lig.net scie...@gmail.com LinkedIn: http://sdw.st/in
V:650-450-UNIX (8649) V:866.SDW.UNIX V:703.371.9362 F:703.995.0407
AIM:sdw Skype:StephenDWilliams Resume: http://sdw.st/gres
Personal: sdw.st facebook.com/sdwlig twitter.com/scienteer

Luiz Valdetaro

unread,
Aug 11, 2011, 8:01:51 PM8/11/11
to andro...@googlegroups.com
Good Idea.

I created a simple little program to test. You know what? it stopped hapenning! So the problem is mine. I will investigate further. I suspect it might have something to do with the fact that I am running my program as a daemon. I will investigate further.

Thanks!

Luiz Valdetaro

unread,
Aug 11, 2011, 8:06:57 PM8/11/11
to andro...@googlegroups.com
Bingo! When I run my program from the command prompt, I get localtime. When I run as a daemon, I get GMT
Reply all
Reply to author
Forward
0 new messages