How can I convert the current time in milliseconds, which is a Long
, to a date in specific format?
The format that I need is yyyy-MM-dd HH:mm
. This should be of type Date
, not String
.
How can I convert the current time in milliseconds, which is a Long
, to a date in specific format?
The format that I need is yyyy-MM-dd HH:mm
. This should be of type Date
, not String
.
You are confused. The type Date
is a number of milliseconds since January 1 1970 midnight UTC. It has no inherent format. There is a default system format for a Date, but you cannot alter it. You will need to format your Date
as a String
if you need that particular String
format.