标签:
//使用方式 numtoUpper("2014") + "年" + monthtoUpper("12") + "月" + daytoUpper("12") + "日" public static string numtoUpper(int num) { String str = num.ToString(); string rstr = ""; int n; for (int i = 0; i < str.Length; i++) { n = Convert.ToInt16(str[i].ToString());//char转数字,转换为字符串,再转数字 switch (n) { case 0: rstr = rstr + "〇"; break; case 1: rstr = rstr + "一"; break; case 2: rstr = rstr + "二"; break; case 3: rstr = rstr + "三"; break; case 4: rstr = rstr + "四"; break; case 5: rstr = rstr + "五"; break; case 6: rstr = rstr + "六"; break; case 7: rstr = rstr + "七"; break; case 8: rstr = rstr + "八"; break; default: rstr = rstr + "九"; break; } } return rstr; } //月转化为大写 public static string monthtoUpper(int month) { if (month < 10) { return numtoUpper(month); } else if (month == 10) { return "十"; } else { return "十" + numtoUpper(month - 10); } } //日转化为大写 public static string daytoUpper(int day) { if (day < 20) { return monthtoUpper(day); } else { String str = day.ToString(); if (str[1] == ‘0‘) { return numtoUpper(Convert.ToInt16(str[0].ToString())) + "十"; } else { return numtoUpper(Convert.ToInt16(str[0].ToString())) + "十" + numtoUpper(Convert.ToInt16(str[1].ToString())); } } } //日期转换为大写 private string dateToUpper(System.DateTime date) { //by 闫磊 Email:Landgis@126.com,yanleigis@21cn.com 2007.10.25 int year = date.Year; int month = date.Month; int day = date.Day; return numtoUpper(year) + "年" + monthtoUpper(month) + "月" + daytoUpper(day) + "日"; }
标签:
原文地址:http://www.cnblogs.com/xianrongbin/p/3635304.html