package com.founder.ibatisDemo.dojo;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author XiaoQin
*
*/
public class DateTestDemo {
public static void main(String[] args) throws Exception {
SimpleDateFormat dateformat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss E");
SimpleDateFormat dateformat0 = new SimpleDateFormat("yyyy");
SimpleDateFormat dateformat1 = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss E");
SimpleDateFormat dateformat2 = new SimpleDateFormat(
"yyyy年MM月dd日 HH时mm分ss秒 E ");
String a0 = dateformat0.format(new Date());
String a1 = dateformat1.format(new Date());
String a2 = dateformat2.format(new Date());
System.out.println("时间1:" + a0);
System.out.println("时间2:" + a1);
System.out.println(new Date().getYear() + "");
System.out.println("时间3:" + a2);
System.out.println("今天 :" + dateformat.format(new Date()));
System.out.println("=======================");
Calendar c = Calendar.getInstance();
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
Date d1 = new Date(c.getTimeInMillis());
System.out.println("星期一:" + dateformat.format(d1));
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
Date d2 = new Date(c.getTimeInMillis());
System.out.println("星期日:" + dateformat.format(d2));
}
}