Date类 和SimpleDateFormat类
日期格式查询Java文档,如下图
package test;
import java.text.SimpleDateFormat;
import java.util.Date;
class Test {
public static void main(String[] args) throws Exception {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
String time = sdf.format(d);
System.out.println("time = " + time);
}
}
package test;
import java.text.SimpleDateFormat;
import java.util.Date;
class Test {
public static void main(String[] args) throws Exception {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
String time = sdf.format(d);
System.out.println("time = " + time);
}
}