使用DateFormat类输出各种格式的时间(上)
来源:互联网 发布:java开源代码库 编辑:程序博客网 时间:2024/06/06 06:16
import java.util.Date;
import java.text.DateFormat;
/**
* 格式化时间类
* DateFormat.FULL = 0
* DateFormat.DEFAULT = 2
* DateFormat.LONG = 1
* DateFormat.MEDIUM = 2
* DateFormat.SHORT = 3
* @author 曲金龙 qujl@neusoft.com
* @version 1.0, 2005/04/16
*/
public class FormatDate{
public static void main(String []args){
Date d = new Date();
String s;
/** Date类的格式: Sat Apr 16 13:17:29 CST 2005 */
System.out.println(d);
System.out.println("******************************************");
/** getDateInstance() */
/** 输出格式: 2005-4-16 */
s = DateFormat.getDateInstance().format(d);
System.out.println(s);
/** 输出格式: 2005-4-16 */
s = DateFormat.getDateInstance(DateFormat.DEFAULT).format(d);
System.out.println(s);
/** 输出格式: 2005年4月16日 星期六 */
s = DateFormat.getDateInstance(DateFormat.FULL).format(d);
System.out.println(s);
/** 输出格式: 2005-4-16 */
s = DateFormat.getDateInstance(DateFormat.MEDIUM).format(d);
System.out.println(s);
/** 输出格式: 05-4-16 */
s = DateFormat.getDateInstance(DateFormat.SHORT).format(d);
System.out.println(s);
System.out.println("******************************************");
}
}
- 使用DateFormat类输出各种格式的时间(上)
- DateFormat类输出各种格式的时间
- java使用DateFormat类,转换时间格式
- DateDemo 时间格式类 SimpleDateFormat DateFormat
- 使用printf输出各种格式的字符串
- 使用printf输出各种格式的字符串
- 日期格式DateFormat使用
- java中Date与DateFormat的格式输出
- java中Date与DateFormat的格式输出
- JAVA DATEFORMAT 格式化时间输出
- 一个时间格式的函数,可以把时间格式为各种输出
- 使用DateFormat把时间长度格式化为"时:分:秒"格式
- Java Calendar,Date,DateFormat,TimeZone,Locale等时间相关内容的认知和使用(4) DateFormat
- 返回时间的各种格式
- 各种时间格式的转换
- 使用DateFormat类获取系统的当前时间
- struts2 <s:property/>标签的使用--输出时间格式转换
- struts2 <s:property/>标签的使用--输出时间格式转换
- wallop邀请
- 中国软件产业落后印度将近10年,原因何在?
- 用回溯法解决背包问题
- XML-RPC学习笔记(一)
- cms
- 使用DateFormat类输出各种格式的时间(上)
- Bill Gates 的大学毕业典礼演讲
- 浅析.NET下XML数据访问新机制
- Opera 8 正式推出
- 使用JBuilder开发J2ME程序
- .net下的安装部署
- 有个词叫“磨人”
- 在 XSL/XSLT 中实现随机排序
- KV2005再次升级破解方法