时间不同国家区域转化问题

        String FromDateTime; //输入的时间

        DateTime dt;

        try

        {

            System.Globalization.CultureInfo cinfo = new System.Globalization.CultureInfo("en-AU");

            dt = Convert.ToDateTime(FromDateTime, cinfo.DateTimeFormat);

        }

        catch

        {

            //抛出异常信息

            return;

        }

 

    今天把索爱的项目挂到服务器上发现代码中多处遇到了时间日期转换的问题,像上面一样所有地方都改过来比较麻烦,只需要在GLOBAL里面加上如下代码即可解决:

    void Application_PreRequestHandlerExecute(object sender, EventArgs e)
    {
            CultureInfo culture = CultureInfo.CreateSpecificCulture("en-AU");
            Thread.CurrentThread.CurrentUICulture = culture;
            Thread.CurrentThread.CurrentCulture = culture;
    }

posted @ 2009-03-17 22:50  潇客的技术博客  阅读(239)  评论(0编辑  收藏  举报