Here you can find the source of convertTicksToMinutesAndSeconds(int ticks, boolean fraction)
Parameter | Description |
---|---|
ticks | a parameter |
fraction | When true, 30 ticks will show as '1.5s' instead of '1s'. |
public static String convertTicksToMinutesAndSeconds(int ticks, boolean fraction)
//package com.java2s; //License from project: GNU General Public License public class Main { /**/*w w w . j a v a2 s. c om*/ * Takes in the amount of ticks, and converts it into a time notation. 40 ticks will become "2s", while 2400 will result in "2m". * @param ticks * @param fraction When true, 30 ticks will show as '1.5s' instead of '1s'. * @return */ public static String convertTicksToMinutesAndSeconds(int ticks, boolean fraction) { String part = ticks % 20 * 5 + ""; if (part.length() < 2) part = "0" + part; ticks /= 20;// first convert to seconds. if (ticks < 60) { return ticks + (fraction ? "." + part : "") + "s"; } else { return ticks / 60 + "m"; } } }