long t=System.currentTimeMillis();Date date = new Date();
long t=System.currentTimeMillis();
date.setTime(t);
System.out.println(date);SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
String fmDate=simpleDateFormat.format(new Date());String sdate = "2020-06-01 06-06-06";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
long time = simpleDateFormat.parse(sdate).getTime();先转换成yyyy-MM-dd HH:mm:ss这个格式,然后可以以字符串格式插入
Date date=new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String fmDate=simpleDateFormat.format(date);参考博客:https://blog.csdn.net/sinat_32238399/article/details/80512452