long date=System.currentTimeMillis()
Date date=new Date();//获取当前时间
//date = Mon May 09 09:17:43 CST 2022
System.out.println(date.getTime());
System.out.println(date.getYear()+1900);
System.out.println(date.getMonth()+1);
System.out.println(date.getDate());
var sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(date));
//格式化后 输出的是字符串