java如何获取当前时间 年月日 时分秒
并且转成java.sql.Date格式。
long l = System.currentTimeMillis();
//new日期对
Date date = new Date(l);
//转换提日期输出格式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(dateFormat.format(date));
String response = dateFormat.format(date).replaceAll("[[\\s-:punct:]]","");
System.out.println("response="+response);
输出结果:
2021-05-07 09:35:47
response=202105
版权声明:本文为qq_42981242原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。