处理日期时出现错误 PlatformNotSupportedException [英] I got error PlatformNotSupportedException when I work with date's

查看:32
本文介绍了处理日期时出现错误 PlatformNotSupportedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 windows-mobile 6.5 上工作

I work on windows-mobile 6.5

地区是English (United States) 日期:M/d/yy 时间:h:mm:ss tt

the region is English (United States) date: M/d/yy time: h:mm:ss tt

我有这个代码:

DateTime dt_1,dt_2;
try
    {
         CultureInfo obj = new CultureInfo("en-US");
         dt_1 = DateTime.Parse(TmpD_from, obj);
    }
catch
    {
          CultureInfo obj = new CultureInfo("he-IL");
          dt_1 = DateTime.Parse(TmpD_from, obj);
    }

try
    {
          CultureInfo obj = new CultureInfo("en-US");
          dt_2 = DateTime.Parse(TmpD_to, obj);
    }
catch
    {
          CultureInfo obj = new CultureInfo("he-IL");
          dt_2 = DateTime.Parse(TmpD_to, obj);
    }

if (DateTime.Today >= dt_1.Date && DateTime.Today <= dt_2.Date)
    {
          return true;
    }
else
    {
           return false;
    }

值:

TmpD_to:   31/12/2011 00:00:00
TmpD_from: 31/12/2011 00:00:00

我收到了这个错误:PlatformNotSupportedException

推荐答案

您可能会收到异常,因为 Windows Mobile 6.5 不支持文化he-IL"(希伯来语,对吧?).我建议尝试另一种文化,其格式设置结果接近(或等于)您想要的.

You probably get the Exception because the culture "he-IL" (Hebrew, right?) is not supported by Windows Mobile 6.5. I would suggest trying another culture, whose formatting results are close (or equal) to what you want.

这篇关于处理日期时出现错误 PlatformNotSupportedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆