2.测试SimpleDateFormat()

package com.cavaness.quartzbook.chapter3;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 测试SimpleDateFormat()
 * @author Kevin
 *
 */
public class DateTest {
	private static Log log = LogFactory.getLog(DateTest.class);
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		DateTest dateTest = new DateTest();
		dateTest.testSimpleDateFormat();
		
	}
	
	public void testSimpleDateFormat() {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); // 用默认的模式和默认语言环境的日期格式符号构造 SimpleDateFormat。
		log.info(simpleDateFormat.format(new Date())); // 12-8-1 上午11:28
		
		SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy.MM.d");
		log.info(simpleDateFormat2.format(new Date())); // 2012.08.1
		
		SimpleDateFormat simpleDateFormat3 = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
		log.info(simpleDateFormat3.format(new Date())); // 2012.08.01 11:32:44
		
		SimpleDateFormat simpleDateFormat4 = new SimpleDateFormat("yyyy.MM.dd E HH:mm:ss");
		log.info(simpleDateFormat4.format(new Date())); // Message:2012.08.01 星期三 11:34:51
		
		SimpleDateFormat simpleDateFormat5 = new SimpleDateFormat("时间:yyyy.MM.dd E HH:mm:ss");// 时间格式中,非ASCII,可以直接写上去,比如"时间:"
		log.info(simpleDateFormat5.format(new Date())); // 时间:2012.08.01 星期三 11:37:01
		
		SimpleDateFormat simpleDateFormat6 = new SimpleDateFormat("时间'time':yyyy.MM.dd E HH:mm:ss");// 时间格式中,ASCII,不可以直接写上去,加上单引号
		log.info(simpleDateFormat6.format(new Date())); // 时间time:2012.08.01 星期三 11:38:57
	}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值