uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/FormatHelper.java [24:60]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class FormatHelper {
	
	public enum Precision { Whole, Tenths };
	
	private static DecimalFormat df = new DecimalFormat("#.0");
	
	static {
		df.setRoundingMode(RoundingMode.DOWN);
	}
	
	public static String duration(final long millis, Precision precision) {
		long seconds = millis / 1000;
		long dd =   seconds / 86400;
		long hh =  (seconds % 86400) / 3600;
		long mm = ((seconds % 86400) % 3600) / 60;
		long ss = ((seconds % 86400) % 3600) % 60;
		String text = String.format("%d:%02d:%02d:%02d", dd, hh, mm, ss);
		if(dd == 0) {
			text = String.format("%02d:%02d:%02d", hh, mm, ss);
			if(hh == 0) {
				text = String.format("%02d:%02d", mm, ss);
				if(mm == 0) {
					text = String.format("%02d", ss);
				}
			}
		}
		switch(precision) {
		case Tenths:
			double subseconds = (millis%1000.0)/1000;
			String frac = df.format(subseconds);
			text = text+frac;
			break;
		case Whole:
		default:
			break;
		}
		return text;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/utils/FormatHelper.java [24:60]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class FormatHelper {
	
	public enum Precision { Whole, Tenths };
	
	private static DecimalFormat df = new DecimalFormat("#.0");
	
	static {
		df.setRoundingMode(RoundingMode.DOWN);
	}
	
	public static String duration(final long millis, Precision precision) {
		long seconds = millis / 1000;
		long dd =   seconds / 86400;
		long hh =  (seconds % 86400) / 3600;
		long mm = ((seconds % 86400) % 3600) / 60;
		long ss = ((seconds % 86400) % 3600) % 60;
		String text = String.format("%d:%02d:%02d:%02d", dd, hh, mm, ss);
		if(dd == 0) {
			text = String.format("%02d:%02d:%02d", hh, mm, ss);
			if(hh == 0) {
				text = String.format("%02d:%02d", mm, ss);
				if(mm == 0) {
					text = String.format("%02d", ss);
				}
			}
		}
		switch(precision) {
		case Tenths:
			double subseconds = (millis%1000.0)/1000;
			String frac = df.format(subseconds);
			text = text+frac;
			break;
		case Whole:
		default:
			break;
		}
		return text;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



