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);
本文提供了一个关于如何在Java中将Timestamp类型与String类型进行相互转换的例子,包括使用Timestamp.valueOf()方法从字符串创建时间戳,以及利用SimpleDateFormat将时间戳格式化为字符串。
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);
1万+

被折叠的 条评论
为什么被折叠?