我想将Indian DateTime对象转换为Eastern DateTime对象。意思是我想改变特定DateTime对象的时区。为此,我写了下面的代码:TimeZone Not Found异常
string easternZoneId = "Eastern Standard Time";
TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById(easternZoneId);
string indianZoneId = "India Standard Time";
TimeZoneInfo indianZone = TimeZoneInfo.FindSystemTimeZoneById (indianZoneId);
DateTime d = TimeZoneInfo.ConvertTime (DateTime.Today, indianZone, easternZone);
当我尝试运行此声明时,我得到,在控制台中出现异常。
如何运行该代码?我想把我的时间转换成东部时间。
编辑:现在我正在Unity编辑器中运行我的代码。我有iMac系统。 我想为iPhone设备运行此代码。
是您_really_确定您的系统具有这些ID在注册表项'HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Time Zones'?你有没有使用'GetSystemTimeZones'方法并检查结果?你的环境/平台是什么? –
@SonerGönül,我还没有使用过GetSystemTimeZones。我可以使用iPhone设备的上述代码吗? – Siddharth
也许你应该添加你使用Mono的平台。 –