【问题标题】:Convert Full Date and Day转换完整日期和日期
【发布时间】:2013-05-28 14:01:39
【问题描述】:

我想知道是否可以转换完整日期和日期,例如

2013 年 4 月 18 日星期四

string (DD/MM/YYYY)

【问题讨论】:

  • 是的,有可能。
  • 如果您想要特定实体/类型的特定输出,请向我们展示代码和您想要的结果。
  • 一种原则上可以解决此问题的编程语言称为Convert-Full-Date-and-Day Complete语言。 C# 设计为完整的转换完整日期和日期。

标签: c# asp.net


【解决方案1】:
【解决方案2】:

您可以尝试使用DateTime.Parse(string str) 方法。

例如, DateTime.Parse("Thu, 18 April 2013");

给出以下输出,

04/18/2013 00:00:00

【讨论】:

    【解决方案3】:

    可能有一种更简单的方法,但根据我对您问题的理解,这是一种快速的方法。有一些额外的代码,这样你就可以添加到一个空白的 Windows 窗体项目中并查看值。

    String strEntry = @"Thursday 18th of April 2013";
    DateTime dteValue = DateTime.MinValue;
    strEntry = strEntry.Replace("of", null);
    strEntry = strEntry.Replace("rd ", " ");
    strEntry = strEntry.Replace("th", null);
    strEntry = strEntry.Replace("st", null);
    DateTime.TryParse(strEntry, out dteValue);
    String strFormat = dteValue.ToString("dd/MM/yyyy");
    MessageBox.Show(strFormat, "Date Value", MessageBoxButtons.OK);
    

    【讨论】:

    • 不会 strEntry.Replace("rd", null);在星期六替换 rd。
    猜你喜欢
    • 1970-01-01
    • 2020-11-03
    • 1970-01-01
    • 1970-01-01
    • 2021-03-27
    • 2020-06-04
    • 1970-01-01
    • 2018-12-16
    • 1970-01-01
    相关资源
    最近更新 更多