My question is simple
If I do:
var start = System.currentTimeMillis
I get:
start: Long = 1542717303659
How should I do to get a string looking to something readable for a human eye?:
ex: “20/11/2018 13:30:10”
My question is simple
If I do:
var start = System.currentTimeMillis
I get:
start: Long = 1542717303659
How should I do to get a string looking to something readable for a human eye?:
ex: “20/11/2018 13:30:10”
3
Answers
You can use the
java.time
library like:If you only have the timestamp, this solution gets a bit more complex:
Then I would take
java.text.SimpleDateFormat
:To get back to the Timestamp:
Don’t overthink it: nothing wrong with just
new Date(start).toString
You can use java.time library and get it in readable format as below one-liner.
I’m just diving the Milliseconds by 1000, so that we get EpochSecond.
For getting it back,