-1

I receive date and time from openweather api in such format "dt":1489602000", I don't know what that mean. I want to receive something like this "2014-07-23 09:00:00" How can I transform it using SimpleDateFormat

  • Based on the docs *"dt Time of data calculation, unix, UTC"* - I would suggest that the value is actually the number of seconds since the Unix Epoch – MadProgrammer Mar 15 '17 at 22:35

1 Answers1

2
String transformedDate = new SimpleDateFormat("H:mm  dd MMM yy").format(new Date(yourTime*1000));

Customize your date format like there

Dmitry
  • 116
  • 1
  • 6
  • 1
    Adding a brief explanation of how your code works would be helpful to both the asker and future readers. – Neil Mar 15 '17 at 23:45
  • FYI, the troublesome old date-time classes such as [`java.util.Date`](https://docs.oracle.com/javase/8/docs/api/java/util/Date.html), [`java.util.Calendar`](https://docs.oracle.com/javase/8/docs/api/java/util/Date.html), and `java.text.SimpleTextFormat` are now [legacy](https://en.wikipedia.org/wiki/Legacy_system), supplanted by the [java.time](https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html) classes. – Basil Bourque Mar 16 '17 at 06:06