milliseconds to days

前端 未结 5 840
情深已故
情深已故 2020-12-13 03:58

i did some research, but still can\'t find how to get the days... Here is what I got:

int seconds = (int) (milliseconds / 1000) % 60 ;
int minutes = (int) ((         


        
5条回答
  •  执念已碎
    2020-12-13 04:17

    public static final long SECOND_IN_MILLIS = 1000;
    public static final long MINUTE_IN_MILLIS = SECOND_IN_MILLIS * 60;
    public static final long HOUR_IN_MILLIS = MINUTE_IN_MILLIS * 60;
    public static final long DAY_IN_MILLIS = HOUR_IN_MILLIS * 24;
    public static final long WEEK_IN_MILLIS = DAY_IN_MILLIS * 7;
    

    You could cast int but I would recommend using long.

提交回复
热议问题