Well you could use a stringbuilder but probably easier to use a date formatter
Date date = new Date(System.currentTimeMillis() - startTime);
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
String dateFormatted = formatter.format(date);
Where startTime is a variable defined as:
long startTime = System.currentTimeMillis();
Hope I helped
Apaec
Edit: As I was saying before, here's an example of a timeformatter using a stringbuilder:
public static String timeFormat(long time) {
StringBuilder t = new StringBuilder();
long total_secs = time / 1000L;
long total_mins = total_secs / 60L;
long total_hrs = total_mins / 60L;
long total_days = total_hrs / 24L;
int secs = (int) total_secs % 60;
int mins = (int) total_mins % 60;
int hrs = (int) total_hrs % 24;
int days = (int) total_days;
if (days < 10) {
t.append("0");
}
t.append(days).append(":");
if (hrs < 10) {
t.append("0");
}
t.append(hrs).append(":");
if (mins < 10) {
t.append("0");
}
t.append(mins).append(":");
if (secs < 10) {
t.append("0");
}
t.append(secs);
return t.toString();
}