Folks!! I am super new to programming and I am creating an app to help out at my work. There is a calculation that is made that returns a result in time. It is a distance divided by speed. I have got as far as to get the result to show up in a TextView. But it is displayed as decimal. I need it to be displayed as 00:00 (minutes:seconds) and, if possible, 00:00:00 (hours:minutes:seconds) but only when time exceeds 60 minutes. If not, it would be great to omit the first "00" for "hour" just evoid visual pollution. So the exact numbers are: time = 217/9.5 which results 22.84210. I need this number to be displayed as 22:50.
See below the little I have got so far.... Please, note that I am at the very basics so it is very problable that you guys may see some heresies in my coding. Sorry for that.
btn_vel_gal.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
double val_gal = Integer.parseInt(velocidadegaleria.getText().toString());
double val_tempo_d3_f1 = ( 217 / val_gal);
tempo_d3_f1.setText(String.valueOf(val_tempo_d3_f1));
DecimalFormat precision = new DecimalFormat("0.00");
tempo_d3_f1.setText(precision.format(val_tempo_d3_f1));
val_gal is the variable where the 9.5 comes from.
Please, if any of you guys could be so kind as to help me. And please, be very didactic as to where exactly i should insert the piece of coding, showing exactly where i need to get from because I am haveing a hard time figuring out what components my coding lines need to get this to work.
Thank you all in advance