This question already has answers here:
Formatting timestamp in Java
(3 answers)
Closed 2 years ago.
IP:
test: String = 2018-10-12 07
Expected OP:
test_timestamp: Timestamp = 2018-10-12 07
Code:
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())
My OP:
timestamp: java.sql.Timestamp = 2018-10-12 07:00:00.0
I am trying to convert to the same datehour format.
Code:
var dateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
timestamp = dateFormat.format(timestamp);
Error:
found : String
required: java.sql.Timestamp
timestamp = dateFormat.format(timestamp);
^
the variable "timestamp" is clearly of type java.sql.Timestamp, so I am not able to understand the issue. Any suggestions.