IP:
test: String = 2018-10-12 07
预期的操作次数:
test_timestamp: Timestamp = 2018-10-12 07
代码:
val format1 = new SimpleDateFormat("yyyy-MM-dd HH")
var d = format1.parse(test)
var date = new Date(d.getTime())
var timestamp = new Timestamp(d.getTime())
我的OP:
timestamp: java.sql.Timestamp = 2018-10-12 07:00:00.0
我正在尝试转换为相同的datehour格式。
代码:
var dateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
timestamp = dateFormat.format(timestamp);
错误:
found : String
required: java.sql.Timestamp
timestamp = dateFormat.format(timestamp);
^
变量“ timestamp”显然是java.sql.Timestamp类型的,因此我无法理解该问题。有任何建议。