**/ /// <summary>
/// Summary description for NumToChinese
/// </summary>
/// <summary>
/// 将日期转换为中文形式,日期是从身份证上取下的,暂不作数据有效性验证,形式为年:2004 月03 日26
/// 从身份证取出生日期的程序就不写了
/// </summary>
using System;
using System.Collections.Generic;
using System.Text;
public class NumToChinese
{
private const string chinese = "○一二三四五六七八九";
public static string ConvertYear(string year)
{
StringBuilder result = new StringBuilder();
for (int i = 0; i < year.Length; i++)
{
result.Append(chinese[int.Parse(year[i].ToString())]);
}
return result.ToString();
}
//从身份证取下来的月,例如01,10,12
public static string ConvertMonth(string month)
{
StringBuilder result = new StringBuilder();
if (month[0].ToString() == "0") //如果是1-9月份
{
result.Append(chinese[int.Parse(month[1].ToString())]);
}
else
if (month == "10") //如果是10月份
{
result.Append("十");
}
else //如果是11,12月份
{
result.Append("十");
result.Append(chinese[int.Parse(month[1].ToString())]);
}
return result.ToString();
}
//从身份证取下来的日,例如01,08,10,22
public static string ConvertDay(string day)
{
StringBuilder result = new StringBuilder();
if (day[0].ToString() == "0") //如果是个位数
{
result.Append(chinese[int.Parse(day[1].ToString())]);
}
else
if (day[1].ToString() == "0") //如果是10,20,30
{
if(day[0].ToString() == "1") //如果是10
{
}
else //如果是20,30
{
result.Append(chinese[int.Parse(day[0].ToString())]);
}
result.Append("十");
}
else //如果是11,25,31
{
if(day[0].ToString() == "1") //如果是11-19
{
}
else //如果是21-29,31
{
result.Append(chinese[int.Parse(day[0].ToString())]);
}
result.Append("十");
result.Append(chinese[int.Parse(day[1].ToString())]);
}
return result.ToString();
}
}