示例代码:
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Demo_SimpleDateFormat {
public static void main(String[] args) throws ParseException {
}
public static void demo4() throws ParseException {
String str = "2008年08月08日 08:08:08";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
System.out.println(sdf.parse(str));
}
public static void demo3() {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(d));
}
public static void demo2() {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat();
System.out.println(sdf.format(d));
}
public static void demo1() {
DateFormat df1 = DateFormat.getDateInstance();
}
}