Search code examples
c#axaptadynamics-ax-2012

How to convert Dynamics AX Timezone to C# TimeZoneInfo?


I need to convert a Timezone on Dynamics AX 2012 R3 to a TimeZoneInfo on C#. I'm doing this on my C# code. I get an int from Dynamics (Timezone enum).

I get the Timezone enum from table LogisticsPostalAddress.

Are there any methods to convert it? I couldn't find much information on that and I'd really like to avoid creating a code that would do a from X to Y for every single possibility. Would I be able to use that Value provided at the referenced link? Thanks :)


Solution

  • It does not sound cool, but I think you will have to provide the mapping table yourself between the Timezone System Enumeration and the name valid to Instantiate a TimeZoneInfo Object.

    The list of names should be quite static, but remember to catch TimeZoneNotFoundException and InvalidTimeZoneException when using FindSystemTimeZoneById.