Timestamp和String相互转换

Timestamp和String类型相互转换例子:

      String str = "2018-05-06 10:30:40";
      //String 转 Timestamp
      Timestamp time = Timestamp.valueOf(str);
       //Timestamp 转 String
       String strn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time);

猜你喜欢

转载自blog.csdn.net/wujian_csdn_csdn/article/details/105555252