java.text.SimpleDateFormat sf = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.util.Date d = sf.parse("2000-11-11 14:23:20");
System.out.println(d);
String s = sf.format(d);
System.out.println(s);
java.util.Date d = sf.parse("2000-11-11 14:23:20");
System.out.println(d);
String s = sf.format(d);
System.out.println(s);
java.text.DateFormat
怎么把字符串转化成Date类型?
DataFormat.getDateInstance().parse("2006-6-6")
当前时间
DataFormat.getDateTimeInstance().format(new Date())
Date date =
new
Date();
DateFormat df =
new
SimpleDateFormat(
"yyyy
年MM月dd日"
);
java.text.SimpleDateFormat formatter =
new
java.text.SimpleDateFormat(
"yyyy-MM-dd-H-mm-ss"
);
Date date =
new
Date();
java.text.SimpleDateFormat formatter =
new
java.text.SimpleDateFormat(
"yyyy-MM-dd H:mm:ss"
);
System.out.println(formatter.format(date));
时间的类型是java.util.Date
Date date = new Date();
System.out.println(date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds());