I want to display the value of the millisecond timer in the game.
String.formaton Android is very slow, so I can not use it. I am currently using this:
long elapsedMillis = ...;
int whole = (int)(elapsedMillis / 1000);
int fraction = (int)(elapsedMillis % 1000);
StringBuilder sb = new StringBuilder("TIME:");
sb.append(whole);
sb.append('.');
if(fraction < 10)
sb.append("00");
else if(fraction < 100)
sb.append("0");
sb.append(fraction);
g.drawText(sb.toString(), ...);
but I think it can be done faster. Can you steer me in the right direction? Thanks
related question
source
share