asp.net 日期转换为大写汉字

//年份转换为大写汉字
public static string numtoUpper(int num)
{
return "零壹贰叁肆伍陆柒捌玖"[num].ToString();
} //月份转换大写汉字
public static string monthtoUpper(int month)
{
if (month < )
{
return numtoUpper(month);
}
else
{
if (month == ) { return "壹拾"; } else
{
return "壹拾" + numtoUpper(month - );
}
}
} //日期转化为大写汉字
public static string daytoUpper(int day)
{
if (day < )
{
return monthtoUpper(day);
}
else
{
String str = day.ToString();
if (str[] == '')
{
return numtoUpper(Convert.ToInt16(str[].ToString())) + "拾";
}
else
{
return numtoUpper(Convert.ToInt16(str[].ToString())) + "拾"
+ numtoUpper(Convert.ToInt16(str[].ToString()));
}
}
}
static void Main(string[] args)
{
string year = "";
string retur = string.Empty;
for (int i = ; i < year.Length; i++)
{
retur += numtoUpper(int.Parse(year[i].ToString())).ToString();
}
Console.WriteLine(retur + " 年");
retur = string.Empty;
string month = "";
retur = monthtoUpper(Convert.ToInt32(month));
Console.WriteLine(retur + " 月");
string day = "";
retur = daytoUpper(Convert.ToInt32(day));
Console.WriteLine(retur + " 日");
Console.ReadLine();
}
上一篇:LeetCode练题——67. Add Binary


下一篇:【LeetCode】67. Add Binary 解题报告(Python)