用DateTimeFormatInfo格式化日期时间
来源:互联网 发布:淘宝修改最低折扣 编辑:程序博客网 时间:2024/06/03 15:46
using System.Globalization;
public class MainClass {
public static void Main(string[] args) {
DateTime dt = DateTime.Now;
String[] format = {
"d", "D",
"f", "F",
"g", "G",
"m",
"r",
"s",
"t", "T",
"u", "U",
"y",
"dddd, MMMM dd yyyy",
"ddd, MMM d /"'/"yy",
"dddd, MMMM dd",
"M/yy",
"dd-MM-yy",
};
String date;
for (int i = 0; i < format.Length; i++) {
date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);
Console.WriteLine(String.Concat(format[i], " :" , date));
}
/** Output.
*
* d :08/17/2000
* D :Thursday, August 17, 2000
* f :Thursday, August 17, 2000 16:32
* F :Thursday, August 17, 2000 16:32:32
* g :08/17/2000 16:32
* G :08/17/2000 16:32:32
* m :August 17
* r :Thu, 17 Aug 2000 23:32:32 GMT
* s :2000-08-17T16:32:32
* t :16:32
* T :16:32:32
* u :2000-08-17 23:32:32Z
* U :Thursday, August 17, 2000 23:32:32
* y :August, 2000
* dddd, MMMM dd yyyy :Thursday, August 17 2000
* ddd, MMM d "'"yy :Thu, Aug 17 '00
* dddd, MMMM dd :Thursday, August 17
* M/yy :8/00
* dd-MM-yy :17-08-00
*/
}
}
- 用DateTimeFormatInfo格式化日期时间
- 用DateTimeFormatInfo格式化日期时间(C#)
- datetimeformatinfo
- 用SimpleDateFormat格式化日期和时间
- 格式化时间日期函数
- 时间日期格式化
- JAVA格式化时间日期
- 格式化时间日期
- .net日期时间格式化
- 时间日期格式化操作
- rails 格式化日期时间
- 格式化 日期时间 DateTime
- Mysql 格式化日期/时间
- C#格式化日期时间
- Mysql 格式化日期/时间
- C#日期格式化,时间
- JAVA格式化日期时间
- Python格式化日期时间
- 开车从西安到重庆几个小时呢?怎么走?
- Android中 View not attached to window manager错误的解决办法
- ............
- 深入理解asp.net SessionState
- 超级链接中的target关键字
- 用DateTimeFormatInfo格式化日期时间
- 清除假脱机请求
- Activity横竖屏切换生命周期
- Java实践之路——WebService
- linux sticky bit 目录权限 rwt权限
- Python科学计算
- 一个简单实用的内存池实现之二 (C实现)
- vector::erase()方法的详细介绍及问题解答
- SQL触发器的使用及语法