I am currently trying to create a timer for an android game which has the form ##.## at all times.
The issue I am having is that if my timer reaches say 23.50, it will set it as 23.5
So, I am trying to set the precision of my double value to be exactly 2 decimal places. This is my code so far, which doesn’t work. Any suggestions are much appreciated, thanks.
public void onTick(long millisUntilFinished) {
double time1 = (double) millisUntilFinished/1000;
DecimalFormat df = new DecimalFormat("##.##");
timerDisplay.setText(df.format(time1));
}
You can use: