Realization of Chinese characters with date converted to uppercase based on ASP. NET

  • 2021-08-12 02:31:03
  • OfStack

This article mainly introduces the use of ASP. NET to convert the date format into capital Chinese characters, for example, "December 3, 2013" is converted into "December 3, 2013". Let's take a look at how to achieve it.

1 sample words don't say much, directly on the code


// The year is converted to capitalized Chinese characters 
  public static string numtoUpper(int num)
   {
    return " Zero one two three four five six seven eight nine "[num].ToString();
   }

// Month conversion capitalized Chinese characters 
  public static string monthtoUpper(int month)
  {
   if (month < 10)
   {
    return numtoUpper(month);
   }
   else
   {
    if (month == 10) { return " Ten "; }

    else
    {
     return " Ten " + numtoUpper(month - 10);
    }
   }
  }


// Date is converted to capitalized Chinese characters 
  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())) + " Pick up ";
    }
    else
    {
     return numtoUpper(Convert.ToInt16(str[0].ToString())) + " Pick up "
      + numtoUpper(Convert.ToInt16(str[1].ToString()));
    }
   }
  }

static void Main(string[] args)
  {
   string year = "2013";
   string retur = string.Empty;
   for (int i = 0; i < year.Length; i++)
   {
    retur += numtoUpper(int.Parse(year[i].ToString())).ToString();
   }
   Console.WriteLine(retur + "  Year ");
   retur = string.Empty;
   string month = "12";
   retur = monthtoUpper(Convert.ToInt32(month));
   Console.WriteLine(retur + "  Month ");
   string day = "3";
   retur = daytoUpper(Convert.ToInt32(day));
   Console.WriteLine(retur + "  Day ");
   Console.ReadLine();
  }

The above is the use of ASP.NET to date format into capital Chinese characters, I hope the content of this article can be helpful when you use ASP.NET.


Related articles: