I am working on a task. I want to remove the date of birth from my ID card with 15 or 18 digits in the form of 19800825, and then convert the date from year to month to Chinese: O, 8, and 25. below isSource code:
/**/ /// <Summary>
/// Summary Description for numtochinese
/// </Summary>
/// <Summary>
/// The date is converted to the Chinese format. The date is removed from the ID card and is not verified for data validity.
/// The procedure for getting the birth date from the ID card will not be written.
/// Joeliang
/// 2007.7.5
/// </Summary>
Using System;
Using System. Collections. Generic;
Using System. text;
Public Class Numtochinese
{
Private Const String Chinese = " ○ September " ;
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 ();
}
// The month from the ID card, for example, 12.
Public Static String Convertmonth ( String Month)
{
Stringbuilder result = New Stringbuilder ();
If (Month [ 0 ]. Tostring () = " 0 " ) // For months from 1 to 9
{
Result. append (Chinese [Int. Parse (month [1]. Tostring ()]);
}
Else
If (Month = " 10 " ) // If it is July
{
Result. append ("10");
}
Else // For months 11,12
{
Result. append ("10");
Result. append (Chinese [Int. Parse (month [1]. Tostring ()]);
}
Return Result. tostring ();
}
// The date obtained from the ID card, for example
Public Static String Convertday ( String Day)
{
Stringbuilder result = New Stringbuilder ();
If (Day [ 0 ]. Tostring () = " 0 " ) // If it is a single digit
{
Result. append (Chinese [Int. Parse (day [1]. Tostring ()]);
}
Else
If (Day [ 1 ]. Tostring () = " 0 " ) // For 10, 20, 30
{
If (Day [ 0 ]. Tostring () = " 1 " ) // If it is 10
{
}
Else // If it is 20, 30
{
Result. append (Chinese [Int. Parse (day [0]. Tostring ()]);
}
Result. append ( " 10 " );
}
Else // If it is 11,25, 31
{
If (Day [ 0 ]. Tostring () = " 1 " ) // If it is 11-19
{
}
Else // If it is 21-29,31
{
Result. append (Chinese [Int. Parse (day [0]. Tostring ()]);
}
Result. append ( " 10 " );
Result. append (Chinese [ Int . Parse (day [ 1 ]. Tostring ()]);
}
Return Result. tostring ();
}
}