更改DateTime错误的语言

时间:2017-06-01 17:23:45

标签: c# datetime

所以我试图将C#中的DateTime语言从英语改为法语。它昨天工作得很好,做了一些改动(与日期完全无关)今天回来并遇到这个错误:

类型为System.FormatException的异常在msorlib.dll中发生但未在用户代码中处理。附加信息:字符串未被识别为有效的DateTime。

这是我的代码:

        string period;

        period = Convert.ToString(Request.QueryString["Period"]);
        string format = "dddd, MMMM dd, yyyy";

        string fDate = from.ToLongDateString();
        var fr = DateTime.ParseExact(fDate, format, new CultureInfo("en-US"));
        var fromDate = fr.ToString("D", new CultureInfo(this.BGUser.UICultureInfoString));

        string tDate = to.ToLongDateString();
        var td = DateTime.ParseExact(tDate, format, new CultureInfo("en-US"));
        var toDate = td.ToString("D", new CultureInfo(this.BGUser.UICultureInfoString));

        if (period == null)
            return "<b>" + this.Translate("Orders due ", 4386) + fromDate + " - " + toDate + "</b>";
        else if (period.Equals("archive"))
            return "<b>" + this.Translate("Orders due before ", 4387) + toDate + "</b>";
        else if (period.Equals("future"))
            return "<b>" + this.Translate("Orders due after ", 4388) + fromDate + "</b>";

具体是在线上获取错误

        var fr = DateTime.ParseExact(fDate, format, new CultureInfo("en-US"));

from和to是传递给函数且正确的DateTime变量。非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

感谢您的评论。我考虑了你的意见,并做了这似乎工作

# ssh to 3.x server
$ cbtransfer -b <bucket> http://<3.x.server.ip>:8091 bucket-backup
# copy back-up data to 4.x server from 3.x server using scp or similar tool
# ssh 4.x server
$ cbtransfer -B <bucket> http://<4.x.server.ip>:8091 bucket-backup