数字日期转化为汉字日期格式

  • 格式:doc
  • 大小:43.00 KB
  • 文档页数:5

下载文档原格式

  / 10
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

数字日期转化为汉字日期格式

1.

2.

48.

49.

50. YYYY-MM-DD:

51.

52. 中文显示:

53.

54.

55. value="转换">

56.

57.

C#

1. ///

2. /// 数字日期转换成中文日期

3. ///

4. /// 日期

5. ///

6. public string changeDate(string strDate)

7. {

8. char[] strChinese;

9. strChinese = new char[] { '〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十

' };

10. StringBuilder result = new StringBuilder();

11. // 依据正则表达式判断参数是否正确

12. Regex theReg = new Regex(@"(d{2}|d{4})(/|-)(d{1,2})(/|-)(d{1,2})");

13. //if (theReg.Match(strDate).Length != 0)

14. //{

15. // 将数字日期的年月日存到字符数组str中

16. string[] str = null;

17. if (strDate.Contains("-"))

18. {

19. str = strDate.Split('-');

20. }

21. else if (strDate.Contains("/"))

22. {

23. str = strDate.Split('/');

24. }

25.

26. // str[0]中为年,将其各个字符转换为相应的汉字

27. for (int i = 0; i < str[0].Length; i++)

28. {

29. result.Append(strChinese[int.Parse(str[0][i].ToString())]);

30. }

31. result.Append("年");

32.

33. // 转换月

34. int month = int.Parse(str[1]);

35. int MN1 = month / 10;

36. int MN2 = month % 10;

37.

38. if (MN1 > 1)