/**
* 关于日期的使用
*/
package javaReview;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TestDate {
public static void main(String[] args) throws ParseException {
Date date = new Date();
DateFormat d1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s = d1.format(date);
System.out.println(s);
}
}
DateFormat d1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
HH表示24小时制
DateFormat d1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
hh表示12小时制