string.Format 格式化输出日期

string.Format("{0:d}",System.DateTime.Now) 结果为:2009-3-20 (月份位置不是03)

string.Format("{0:D}",System.DateTime.Now) 结果为:2009年3月20日

string.Format("{0:f}",System.DateTime.Now) 结果为:2009年3月20日 15:37

string.Format("{0:F}",System.DateTime.Now) 结果为:2009年3月20日 15:37:52

string.Format("{0:g}",System.DateTime.Now) 结果为:2009-3-20 15:38

string.Format("{0:G}",System.DateTime.Now) 结果为:2009-3-20 15:39:27

string.Format("{0:m}",System.DateTime.Now) 结果为:3月20日

string.Format("{0:t}",System.DateTime.Now) 结果为:15:41

string.Format("{0:T}",System.DateTime.Now) 结果为:15:41:50

时间: 2024-08-28 20:27:45

string.Format 格式化输出日期的相关文章

C# String.Format格式化json字符串中包含"{" "}"报错问题

json.Append(String.Format("{\"total\":{0},\"row\":{1}}", lineCount, strJSON));直接会报错 字符串中包含{或者},则需要用{{ 来代替字符 {,用}} 代替 }如:json.Append(String.Format("{{\"total\":{0},\"row\":{1}}}", lineCount, strJS

java笔记--String类格式化当天日期转换符文档

String类格式化当天日期 转换符:%tb : 格式化为月份的英文缩写%tB : 格式化为月份的英文全写%ta : 格式化为星期%tA : 格式化为星期%ty : 格式化为两位年份值%tY : 格式化为四位年份值%tm : 格式化为两位月份值%td : 格式化为两位日期值%te : 格式化为星期一位日期值%tH : 格式化为两位24时制小时值(00-23)%tk : 格式化为两位24时制小时值(0-23)%tI : 格式化为两位12时制小时值(01-12)%tl : 格式化为两位12时制小时值

string.Format 格式化日期格式

DateTime dt = DateTime.Now;//2010年10月4日 17点05分            string str = "";            //str = string.Format("{0:y yy yyy yyyy}", dt); //10 10 2010 2010            //str = String.Format("{0:M MM MMM MMMM}", dt); //10 10 十月 十月 

[java工具类01]__构建格式化输出日期和时间的工具类

在之前的学习中,我写过一篇关于字符串格式化的,就主要设计到了时间以及日期的各种格式化显示的设置,其主要时通过String类的fomat()方法实现的. 我们可以通过使用不同的转换符来实现格式化显示不同的时间以及日期信息,但我们了解到,时间以及日期的转换符实在是太多了,导致我们无法十分方便的在需要的时候格式化出想要的日期时间输出格式. 然而在学习过程中,我们了解到类是可以相互调用的,以及静态方法是可以跨类使用的,,所以,通过本文,将构建一个显示时间日期的工具类,定义几个常用的日期时间格式,之后我们

thinkphp 5 前台格式化输出日期

thinkphp格式化输出 {$time|strtotime|date="Y年m月d日",###}   $time 是日期字符串,一般后台的时间是"Y-m-d h:i:s" strtotime()把字符串转化为时间整数 date(format, timestamp) 把整数时间timestamp按照format格式转换为字符串 "###"表示前面的变量在date函数中的传入位置

thinkphp前台格式化输出日期

thinkphp格式化输出 {$time|strtotime|date="Y年m月d日",###} $time 是日期字符串,一般后台的时间是"Y-m-d h:i:s" strtotime()把字符串转化为时间整数 date(format, timestamp) 把整数时间timestamp按照format格式转换为字符串 "###"表示前面的变量在date函数中的传入位置 版权声明:本文为博主原创文章,未经博主允许不得转载.

string.Format格式化用法详解

1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元) string.Format("{0:C}",0.2) 结果为:¥0.20 (英文操作系统结果:$0.20) 默认格式化小数点后面保留两位小数,如果需要保留一位或者更多,可以指定位数 string.Format("{0:C1}",23.15) 结果为:¥23.2 (截取会自动四舍五入) 格式化多个Object实例 string.Format("市场价:{0:C},优惠价{1:C

string.Format 格式化时间,货币

1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元) string.Format("{0:C}",0.2) 结果为:¥0.20 (英文操作系统结果:$0.20) 默认格式化小数点后面保留两位小数,如果需要保留一位或者更多,可以指定位数string.Format("{0:C1}",23.15) 结果为:¥23.2 (截取会自动四舍五入) 格式化多个Object实例string.Format("市场价:{0:C},优惠价{1:C}&

我的Android进阶之旅------>Java字符串格式化方法String.format()格式化float型时小数点变成逗号问题

今天接到一个波兰的客户说有个APP在英文状态下一切运行正常,但是当系统语言切换到波兰语言的时候,程序奔溃了.好吧,又是我来维护. 好吧,先把系统语言切换到波兰语,切换到波兰语的方法查看文章 我的Android进阶之旅------>Android[设置]-[语言和输入法]-[语言]列表中找到相应语言所对应的列表项 地址:http://blog.csdn.net/ouyang_peng/article/details/50209789 ================================