基于ASP.NET實現(xiàn)日期轉(zhuǎ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的時候能有所幫助。
- ASP.NET Core 數(shù)據(jù)保護(Data Protection 集群場景)下篇
- ASP.NET Core 數(shù)據(jù)保護(Data Protection)中篇
- ASP.NET Core 數(shù)據(jù)保護(Data Protection)上篇
- ASP.NET Core Kestrel 中使用 HTTPS (SSL)
- ASP.NET Core集成微信登錄
- 微信搶紅包ASP.NET代碼輕松實現(xiàn)
- ASP.NET?MVC5網(wǎng)站開發(fā)之用戶資料的修改和刪除3(七)
- ASP.NET?MVC5網(wǎng)站開發(fā)之用戶添加和瀏覽2(七)
- ASP.NET?MVC5網(wǎng)站開發(fā)之用戶角色的后臺管理1(七)
- ASP.NET 程序員都非常有用的85個工具
相關(guān)文章
SqlCommandBuilder如何實現(xiàn)批量更新
這篇文章主要介紹了SqlCommandBuilder如何實現(xiàn)批量更新,需要的朋友可以參考下2015-10-10支持ASP.NET MVC、WebFroM的表單驗證框架ValidationSuar使用介紹
這篇文章主要介紹了支持ASP.NET MVC、WebFroM的表單驗證框架ValidationSuar使用介紹,本文詳細講解了使用步驟,并給出一個完整Demo下載,需要的朋友可以參考下2015-06-06CKEditor與dotnetcore實現(xiàn)圖片上傳功能
這篇文章主要為大家詳細介紹了CKEditor與dotnetcore實現(xiàn)圖片上傳功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-09-09asp.net GridView控件鼠標移動某行改變背景顏色(方法一)
asp.net GridView控件鼠標移動某行改變背景顏色2009-12-12.Net語言Smobiler開發(fā)之如何在手機上實現(xiàn)表單設(shè)計
這篇文章主要為大家詳細介紹了.Net語言APP開發(fā)平臺,如何在手機上實現(xiàn)表單設(shè)計(Smobiler),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-09-09Net Core Web Api項目與在NginX下發(fā)布的方法
這篇文章主要介紹了Net Core Web Api項目與在NginX下發(fā)布的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-03-03asp.net+js實現(xiàn)的ajax sugguest搜索提示效果
阿會楠根據(jù)網(wǎng)上一份原作者不詳?shù)拇a進行了修改,以適合自己的項目并增加了多個功能。此次放出的代碼為基本實現(xiàn)代碼,也是最接近原來的代碼,略去其他功能。版權(quán)歸原作者所有。2009-04-04