无为清净楼资源网 Design By www.qnjia.com
这篇文章主要介绍的是利用ASP.NET将日期格式转为大写汉字,比如: “2013年12月3日” 转换成 “贰零壹叁年拾贰月叁日”,下面一起来看看怎么实现。
一样话不多说,直接上代码
//年份转换为大写汉字 public static string numtoUpper(int num) { return "零壹贰叁肆伍陆柒捌玖"[num].ToString(); } //月份转换大写汉字 public static string monthtoUpper(int month) { if (month < 10) { return numtoUpper(month); } else { if (month == 10) { return "壹拾"; } else { return "壹拾" + numtoUpper(month - 10); } } } //日期转化为大写汉字 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将日期格式转为大写汉字的全部内容,希望本文的内容对大家使用ASP.NET的时候能有所帮助。
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月27日
2024年09月27日
- 群星《完美的她 影视原声带》[FLAC/分轨][141.05MB]
- 山风点伙.1997-深藏不露【立得】【WAV+CUE】
- 李幸倪.2018-First.Of.All.Live.Concert.3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 李恕权.2003-回·20年全精选2CD【SONY】【WAV+CUE】
- 群星《你就在我身边 电影原声专辑》[320K/MP3][26.68MB]
- 群星《你就在我身边 电影原声专辑》[FLAC/分轨][70.27MB]
- 班得瑞原装进口《20周年精选集》1CD[APE/CUE分轨][303MB]
- 群星.2009-NOON.D.广东.2CD【新世纪】【WAV+CUE】
- 洪卓立.2012-GROWN.UP【英皇娱乐】【WAV+CUE】
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 金佩姗.1997-喜新恋旧【现代派】【WAV+CUE】
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 陈晓东.1997-在乎你感受(EP)【宝丽金】【WAV+CUE】
- 纯音入心系列纯音乐《云水禅心 - 佛曲古筝礼赞1-2》1CD[MP3][190MB]
- 纯音入心系列纯音乐《精心传神-古筝》1CD[MP3][363.1MB]