-6

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.

Biffen
  • 6,249
  • 6
  • 28
  • 36
Euphoria
  • 25
  • 1
  • 1
  • 6
  • 2
    Possible duplicate of [how to convert long date value to mm/dd/yyyy format](https://stackoverflow.com/questions/11755534/how-to-convert-long-date-value-to-mm-dd-yyyy-format) – takendarkk Apr 18 '18 at 15:05

1 Answers1

3

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.

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249