我查了下Timestamp的说明:toString
public String toString()使用 JDBC 时间戳转义格式编排时间戳。yyyy-mm-dd hh:mm:ss.fffffffff,其中 ffffffffff 指示毫微秒。 覆盖:
类 Date 中的 toString
返回:
使用 yyyy-mm-dd hh:mm:ss.fffffffff 格式的 String 对象
另请参见:
Date.toLocaleString(), Date.toGMTString()我于是写了个测试:
Timestamp t= new Timestamp(System.currentTimeMillis());
Date date= new Date(t.getTime());
DateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.fffffffff"); 然后输出 format.format(date).toString();竟然提示说 DateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.fffffffff"); 有错,
不认识这种格式。和解啊?而直接输出 t.toString() 结果是精确到秒之后三位。
public String toString()使用 JDBC 时间戳转义格式编排时间戳。yyyy-mm-dd hh:mm:ss.fffffffff,其中 ffffffffff 指示毫微秒。 覆盖:
类 Date 中的 toString
返回:
使用 yyyy-mm-dd hh:mm:ss.fffffffff 格式的 String 对象
另请参见:
Date.toLocaleString(), Date.toGMTString()我于是写了个测试:
Timestamp t= new Timestamp(System.currentTimeMillis());
Date date= new Date(t.getTime());
DateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.fffffffff"); 然后输出 format.format(date).toString();竟然提示说 DateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss.fffffffff"); 有错,
不认识这种格式。和解啊?而直接输出 t.toString() 结果是精确到秒之后三位。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货