Alan Vieira Rezende February 2016

Convert double HOURS to MINUTES

I have 2 EDIT Text in my APP with hours and minutes.

i have that double:

    double hour;
                try {
                    hour= Double.parseDouble(dayhour.getText().toString().replace(',', '.'));
                } catch (NumberFormatException e) {
                    hour = 0; 
                }

  double minute;

                try {
                    minute= Double.parseDouble(dayminute.getText().toString().replace(',', '.'));
                } catch (NumberFormatException e) {
                    minute= 0; 
                }

After get hour value i want convert to minutes. because i want know all time in minutes example: 3:42 = 222 minutes.

What i need do?

Answers


Unii February 2016

1)change hours to minutes
2)Add minutes

double allTime = hour * 60 + minute; // allTime - in minutes


Xoce 웃 Пepeúpa February 2016

You can try a very elegant way

minute += TimeUnit.HOURS.toMinutes(hour);

Post Status

Asked in February 2016
Viewed 3,858 times
Voted 5
Answered 2 times

Search




Leave an answer