I'm_With_Stupid I'm_With_Stupid - 3 months ago 10
Java Question

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).

Answer

I'm with stupid,

Here's the pseudo algorithm:

  1. Get the current time in hours and minutes
  2. Multiple hours * 60 + minutes, and this is your answer!

I would recommend using the Date class:

 Date date = new Date();

You can read up more on the Date class here.

Please let me know if you have any questions!