关于Java中的时间转换,防止忘记,就先记一部分
Timestamp 转 指定格式 Date 转 字符串
1 Timestamp timestamp1 = Timestamp.valueOf("2019-07-23 12:00:00") ; 2 Timestamp timestamp2 = new Timestamp(Calendar.getInstance().getTimeInMillis()) ; 3 4 Date date1 = new Date(); 5 date1 = timestamp1 ; 6 Date date2 = new Date(timestamp2.getTime()) ; 7 8 DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 9 String dateStr = "" ; 10 dateStr = sdf.format(date2) ;
共同学习,共同进步,若有补充,欢迎指出,谢谢!