public static void see(String str){
System.out.println(str);
}
public void testDateFormat(){
//2009-11-1
DateFormat df1=DateFormat.getDateInstance();
String date1=df1.format(new Date());
see(date1);
// 21:21:42
DateFormat df2=DateFormat.getTimeInstance();
String date2=df2.format(new Date());
see(date2);
// 2009-11-1 21:23:48
DateFormat df3=DateFormat.getDateTimeInstance();
String date3=df3.format(new Date());
see(date3);
// 09-11-1 下午9:23
DateFormat df4=DateFormat.getInstance();
String date4=df4.format(new Date());
see(date4);
//09-11-2
DateFormat df5=DateFormat.getDateInstance(DateFormat.SHORT);
String str1=df5.format(new Date());
see(str1);
//上午9:11
DateFormat df6=DateFormat.getTimeInstance(DateFormat.SHORT);
String str2=df6.format(new Date());
see(str2);
}
阅读(1160) | 评论(0) | 转发(0) |