Don't drop zeros in the second position in formatDuration()

Bug: 3223250
Change-Id: I462c96af51cc052f9df1dc3d2c668551b10155ea
This commit is contained in:
Bjorn Bringert
2010-11-23 14:43:12 +00:00
parent 1c24e957ad
commit 901b3796fd
2 changed files with 20 additions and 3 deletions

View File

@ -158,18 +158,17 @@ public class TimeUtils {
static private int printField(char[] formatStr, int amt, char suffix, int pos,
boolean always, int zeropad) {
if (always || amt > 0) {
final int startPos = pos;
if ((always && zeropad >= 3) || amt > 99) {
int dig = amt/100;
formatStr[pos] = (char)(dig + '0');
pos++;
always = true;
amt -= (dig*100);
}
if ((always && zeropad >= 2) || amt > 9) {
if ((always && zeropad >= 2) || amt > 9 || startPos != pos) {
int dig = amt/10;
formatStr[pos] = (char)(dig + '0');
pos++;
always = true;
amt -= (dig*10);
}
formatStr[pos] = (char)(amt + '0');