1

how to convert sunrise and sunset unix timestrap to current hour and minute by openweathermap api in android studio? Thankyou

"sys": {
        "type": 1,
        "id": 9383,
        "country": "ID",
        "sunrise": 1580424864,
        "sunset": 1580469435
    }
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Does this answer your question? [Convert timestamp in milliseconds to string formatted time in Java](https://stackoverflow.com/questions/4142313/convert-timestamp-in-milliseconds-to-string-formatted-time-in-java) – shadow Jan 31 '20 at 03:37
  • check this https://stackoverflow.com/a/18930056/1712446 – Azhagthott Jan 31 '20 at 03:48

1 Answers1

4

first get timestemp and convert by this method

  private void convertDate(long time) {
  Calendar cal = Calendar.getInstance(Locale.ENGLISH);
  cal.setTimeInMillis(time * 1000);
  int hours = cal.get(Calendar.HOUR_OF_DAY);
  int minutes = cal.get(Calendar.MINUTE);
  int seconds = cal.get(Calendar.SECOND);
   }
Avinash
  • 867
  • 4
  • 11