Date date = new Date();
System.out.println(date);
String dateStr = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date);
System.out.println(dateStr);
输出结果像下面这样:
Wed Sep 16 19:02:36 CST 2009
2009-09-16 07:02:36
System.out.println(date);
String dateStr = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(date);
System.out.println(dateStr);
输出结果像下面这样:
Wed Sep 16 19:02:36 CST 2009
2009-09-16 07:02:36