标签:参考资料
1.Calendar使用:JAVAAPI学习之Calendar类
public class CurrentTime {
public static void main(String args[]){
Calendar c=Calendar.getInstance();
SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(c.getTime());
String date="";
date+=c.get(Calendar.YEAR)+"年"+(c.get(Calendar.MONTH)+1)+"月"+
c.get(Calendar.DAY_OF_MONTH)+"日";
System.out.println(date);
String str=sd.format(c.getTime());
System.out.println(str);
String time="";
time+=c.get(Calendar.HOUR_OF_DAY)+":"+
c.get(Calendar.MINUTE)+":"+c.get(Calendar.SECOND);
System.out.println(time);
c.set(2008, 8, 8);
System.out.println(c.getTime());
//2008-9-8
c.set(Calendar.YEAR, 2008);
c.set(Calendar.MONTH, 8);
c.set(Calendar.DAY_OF_MONTH, 8);
System.out.println(c.getTime());
}
}
本文出自 “学而不思则罔” 博客,请务必保留此出处http://dyzyxy.blog.51cto.com/944775/1630285
标签:参考资料
原文地址:http://dyzyxy.blog.51cto.com/944775/1630285