My duration is currently in seconds in double format. how do i convert it do display, how many hours, min, and seconds. if i just divide by 60 there will be a remainder. also, how do i convert my double to Integer? If I just initializes my time as Integer, it will have a error:
"Type mismatch: cannot convert from double to int"` at "time=n*30+r1;"
*EDIT(sorry i written the wrong output):*lets say the seconds is 132 seconds. i want to be in 0 hours, 2 min 12 seconds
double time = 0;
double hourTime=0;
double minTime=0;
btnStartMove.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
startButtonClicked=true;
startDistance=true;
counter= new MyCount(30000,1000);
counter.start();
btnStartMove.setText("Started...");
}
});
//button to get duration
btnDuration.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
if(startButtonClicked=true)
{
time=n*30+r1;
velocity=dist/time;
DecimalFormat df = new DecimalFormat("#.##");
Toast.makeText(MainActivity.this,"Duration :"+String.valueOf(time) + "Speed :"+String.valueOf(df.format(velocity)),Toast.LENGTH_LONG).show();
}
}
});
public class MyCount extends CountDownTimer{
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish() {
counter= new MyCount(30000,1000);
counter.start();
n=n+1;
}
@Override
public void onTick(long millisUntilFinished) {
s1=millisUntilFinished;
r1=(30000-s1)/1000;
}
}}