最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于ASP.NET實現(xiàn)日期轉(zhuǎn)為大寫的漢字

 更新時間:2016年08月17日 11:14:02   投稿:daisy  
在寫代碼時遇到一個需要將日期轉(zhuǎn)換為中文大寫日期的問題,網(wǎng)上找了找,示例不是很多,只有javascript代碼的,下面整理下在ASP.NET中怎么實現(xiàn)。

這篇文章主要介紹的是利用ASP.NET將日期格式轉(zhuǎn)為大寫漢字,比如: “2013年12月3日” 轉(zhuǎn)換成 “貳零壹叁年拾貳月叁日”,下面一起來看看怎么實現(xiàn)。

一樣話不多說,直接上代碼

//年份轉(zhuǎn)換為大寫漢字
  public static string numtoUpper(int num)
   {
    return "零壹貳叁肆伍陸柒捌玖"[num].ToString();
   }

//月份轉(zhuǎn)換大寫漢字
  public static string monthtoUpper(int month)
  {
   if (month < 10)
   {
    return numtoUpper(month);
   }
   else
   {
    if (month == 10) { return "壹拾"; }

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


//日期轉(zhuǎn)化為大寫漢字
  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())) + "拾";
    }
    else
    {
     return numtoUpper(Convert.ToInt16(str[0].ToString())) + "拾"
      + 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 + " 年");
   retur = string.Empty;
   string month = "12";
   retur = monthtoUpper(Convert.ToInt32(month));
   Console.WriteLine(retur + " 月");
   string day = "3";
   retur = daytoUpper(Convert.ToInt32(day));
   Console.WriteLine(retur + " 日");
   Console.ReadLine();
  }

以上就是利用ASP.NET將日期格式轉(zhuǎn)為大寫漢字的全部內(nèi)容,希望本文的內(nèi)容對大家使用ASP.NET的時候能有所幫助。

相關(guān)文章

最新評論

富蕴县| 江川县| 迁西县| 鄢陵县| 白银市| 虹口区| 石门县| 崇左市| 郑州市| 松阳县| 潍坊市| 巴彦县| 大厂| 扎囊县| 开江县| 宁都县| 民权县| 漳平市| 天津市| 平塘县| 祁东县| 伊宁市| 来安县| 阿坝县| 塔河县| 江油市| 长治市| 诏安县| 特克斯县| 红河县| 南开区| 卢湾区| 深圳市| 甘德县| 长岭县| 登封市| 涟源市| 出国| 旌德县| 泸定县| 沙雅县|