/// <summary>
/// 日期转换为中文大写
/// </summary>
public class UpperConvert
{
public UpperConvert()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
//把数字转换为大写
public string numtoUpper(int num)
{
String str=num.ToString();
string rstr = "";
int n;
for (int i = ; i < str.Length; i++)
{
n =Convert.ToInt16(str[i].ToString());//char转数字,转换为字符串,再转数字
switch (n)
{
case :rstr=rstr+"〇";break;
case :rstr=rstr+"一";break;
case :rstr=rstr+"二";break;
case :rstr=rstr+"三";break;
case :rstr=rstr+"四";break;
case :rstr=rstr+"五";break;
case :rstr=rstr+"六";break;
case :rstr=rstr+"七";break;
case :rstr=rstr+"八";break;
default:rstr=rstr+"九";break;
}
}
return rstr;
}
//月转化为大写
public string monthtoUpper(int month)
{
if (month < )
{
return numtoUpper(month);
}
else
if (month == ) { return "十"; }
else
{
return "十" + numtoUpper(month - );
}
}
//日转化为大写
public 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()));
}
}
}
//日期转换为大写
public string dateToUpper(System.DateTime date)
{
int year = date.Year;
int month = date.Month;
int day = date.Day;
return numtoUpper(year) + "年" + monthtoUpper(month) + "月" + daytoUpper(day) + "日";
}
}