mardi 28 février 2017

Simple If issue

I have a program which gets the time in millis. On a button click, I wish to have the text change and state the difference between the time saved (savetime) and the current time. I can get it to display in millis, seconds and minutes, but for some reason I just can't get it to display hours. I'm sure it is a simple issue and can easily be resolved, I just am frustrated and can't get it... this is my latest attempt. Thank you so much!

long count;
long seconds = 1000;
long minutes = 60;
long hours = 3600;
TextView diff = (TextView)findViewById(R.id.diff);
count = (currenttime-savetime)/seconds;
if (count>=60) {
    count = count/minutes;
    diff.setText(difference+count+" minutes.");
} else if (count>=3600) {
    count = count/hours;
    diff.setText(difference+count+" hours.");
} else {
    diff.setText(difference+count+" seconds.");
}

Aucun commentaire:

Enregistrer un commentaire