Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the total number of minutes in the day so far?

How do you get the total number of minutes in the day so far in Java (Android)? Is this possible? For example, if it was 12:37am, I would want it to return int 37 (37 minutes so far that day). Or if it was 1:41am, I would want it to return int 101 (101 minutes so far that day), or if it 12:20pm, it would return int 740 (740 total minutes that day).

like image 972
I'm_With_Stupid Avatar asked Sep 09 '14 03:09

I'm_With_Stupid


People also ask

How do you figure out how many minutes are in a day?

A day is equal to 1440 minutes.

How many minutes are there in a day of 24 hours?

That is, there are 1440 minutes in a day.

What percentage is 20 minutes of a day?

Answer and Explanation: The answer is 1.39%.


1 Answers

I actually used the Calendar class to figure this out.

Here is the code, with currentMinuteOfDay being the total number of minutes.

Calendar now = Calendar.getInstance();
        int hour = now.get(Calendar.HOUR_OF_DAY);
        int minute = now.get(Calendar.MINUTE);

        int currentMinuteOfDay = ((hour * 60) + minute);
like image 69
I'm_With_Stupid Avatar answered Sep 27 '22 22:09

I'm_With_Stupid