I need number of days from milliseconds.
I am doing as,
long days = (millis / (60*60*24*1000)) % 365;
Is this true? If no please tell me how get number of days from milliseconds.
Please don't suggest to do
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);
int mDay = calendar.get(Calendar.DAY_OF_MONTH);
int days = TimeUnit.MILLISECONDS.toDays(miliseconds);
long days = (millis / (60*60*24*1000))
Pretty sure that's correct, but without the modulo.
% 365 means divide it by 365 and get the remainder.
There are (60*60*24*1000) millisecond in a day.
So for conversion:
millis/(60 seconds * 60 minutes * 24 hours * 1000 ms/second)
should do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With