- Home /
Most consistent way to handle Timezones (plus JNI help)
So this is possibly a multi-part question. I want award users who log in every day, but base it upon their local timezone. We have a server in C# running in Mono where the award happens, so I want to transmit timezone to the server.
In the .Net world I can get information out of System.TimeZoneInfo.Local (DisplayName seems the smartest thing to use here, but it's referred to as a "Windows format").
I've found that System.TimeZoneInfo isn't available on Android. There's java.util.TimeZone, though I haven't messed with JNI before, and I'm having some big problems getting there - I need to get an object reference through the static class function getDefault(), and then call getID() on that - which is a more Unix-ish format. Getting this to work was my original reason for coming here.
But now I'm wondering if it's worth the effort, is my server in Mono going to be able to decode the Android timezone identifier? Is there a better way of doing this?
My fallback position will be to tease out the offset from UTC, but I'd much rather handle daylight savings transparently (or outlaw it across the globe). I suppose I could have the user input a timezone, but frankly this should not be my job to ask for it. The OS should be able to provide something useful (or perhaps wishful thinking, Unity could translate to some reasonably portable standard).
So what do people think?
Answer by ludos · May 14, 2014 at 03:06 PM
Hi, i encountered the same problem (Android not having System.TimeZoneInfo informations at all). Have you found any solution to your problem (specifically how to use java.util.TimeZone)? Any hint or example would be great! Thanks
[edit] i used http://www.codeplex.com/zoneinfo in the end. [/edit]
Answer by Lancemaker_ · Jul 30, 2015 at 12:32 AM
Im having the same problem. Im using windows all the methods from System.TimezoneInfo are throwing erros. The System.TimeZoneInfo.GetSystemTimezone should be returning tons of timezones, its returning 0. i really dont know how can i keep working on my app without this function. and the only complaint about it is this page. i hope someone can show us some light.
Your answer
Follow this Question
Related Questions
When will Unity Support .NET 4 to the current Mono Level? 1 Answer
`System.IO.File' does not contain a definition for `AppendText'? 1 Answer
Can I use .NET 4 library or Mono 2.8 in Unity ? 2 Answers
What version of Mono the 2017.1 version use? 1 Answer
Can I use Monodevelop bundled with Unity to debug standalone .NET applications? 0 Answers