Created
March 9, 2013 09:41
-
-
Save javisantana/5123654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Time { | |
public static String formatTime(long t) { | |
StringBuffer o = new StringBuffer(); | |
long dsecs = (t/10)%100; | |
long secs = (t/1000)%60; | |
long mins = t/(60*1000); | |
if(mins < 10) { | |
o.append('0'); | |
} | |
o.append(mins); | |
o.append(':'); | |
if(secs < 10) { | |
o.append('0'); | |
} | |
o.append(secs); | |
o.append(':'); | |
if(dsecs < 10) { | |
o.append('0'); | |
} | |
o.append(dsecs); | |
return o.toString(); | |
//return String.format("%02d:%02d.%02d", mins, secs, dsecs ); | |
} | |
public static String formaDelta(long dt) { | |
StringBuffer o = new StringBuffer(); | |
long t = Math.abs(dt); | |
long dsecs = (t/10)%100; | |
long secs = t/1000; | |
o.append(dt>=0?"+":"-"); | |
if(secs < 10) { | |
o.append('0'); | |
} | |
o.append(secs); | |
o.append(':'); | |
if(dsecs < 10) { | |
o.append('0'); | |
} | |
o.append(dsecs); | |
return o.toString(); | |
//return String.format("%s%02d.%02d", dt>=0?"+":"-", secs, dsecs ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment