java获取取得Timestamp类型的当前系统时间
java获取取得Timestamp类型的当前系统时间 格式:2019-09-20 16:20:10
方法1:
Timestamp d = new Timestamp(System.currentTimeMillis());
方法2:
Date date = new Date();
Timestamp nowdate = new Timestamp(date.getTime());
//Timestamp转化为String,定义格式,不显示毫秒
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp delayDate = new Timestamp(System.currentTimeMillis());
String str = sdf.format(delayDate);
//String转化为Timestamp
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = df.format(new Date());
Timestamp ts = Timestamp.valueOf(time);