【问题标题】:convert timestamp into current hour and minute in android在android中将时间戳转换为当前小时和分钟
【发布时间】:2020-05-16 17:56:36
【问题描述】:

如何通过 android studio 中的 openweathermap api 将日出和日落 unix 时间带转换为当前小时和分钟?谢谢你

"sys": {
        "type": 1,
        "id": 9383,
        "country": "ID",
        "sunrise": 1580424864,
        "sunset": 1580469435
    }

【问题讨论】:

标签: android api time openweathermap


【解决方案1】:

先获取timetemp并通过此方法进行转换

  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);
   }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-11
    • 2013-09-26
    相关资源
    最近更新 更多