how to get date from milliseconds in android

后端 未结 7 1528
情话喂你
情话喂你 2021-01-17 16:32

I have time in milliseconds, now I want to separate time and date from these milliseconds.

how

相关标签:
7条回答
  • 2021-01-17 17:12

    Use a Calendar to get the values of different time fields:

    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(timeInMillis);
    int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
    int monthOfYear = cal.get(Calendar.MONTH);
    
    0 讨论(0)
提交回复
热议问题