How to convert a time zone information in C# to a time zone information in Java?
c#, java, timezone
Solution
You know that "time" is independent of "time zone", so I won't belabor that point :)
"TimeZone" is really more a function of your OS than a programming language.
Android "Time Zone IDs" correspond to the standard, IANA "Olson database":
http://developer.android.com/reference/java/util/TimeZone.html#getTimeZone%28java.lang.String%29
http://en.wikipedia.org/wiki/Tz_database
The other half of the equation is mapping .Net timezones to the "standard". This link should help:
- .NET TimeZoneInfo from Olson time zone
Problem
I have a system which consists of a C# back end and a Java front end. The C# back end communicates with other systems and some mobile devices. On the C# side, my task is among others to recognize the time zone of the timestamps coming from the mobile devices and create the corresponding `TimeZoneInfo` object. This is working without any problems. On the Java side, I have to display the time zone information together with the data sent by a mobile device. I'm using the `TimeZone` class to store the time zone information within my domain objects. Now the question is how can I create a Java's `TimeZon`e object which corresponds with a C#'s `TimeZoneInfo` object? AFAIK the time zones do not have any unique IDs. Further on, the names are also different (e.g. in C#: "`Central Europe Standard Time`", in Java "`Central Europe Time`"). Not even the number of the time zones in C# and in Java is equal!