public class Util { public static long textToTick(String str) { if(str == null || str.equals("")) return 0; String[] strs = str.split(":|\\."); long ticks = 0; try { switch (strs.length) { case 1: ticks += Integer.parseInt(strs[0]); break; case 2: ticks += Integer.parseInt(strs[1]); ticks += Integer.parseInt(strs[0]) * 1000; break; case 3: ticks += Integer.parseInt(strs[2]); ticks += Integer.parseInt(strs[1]) * 1000; ticks += Integer.parseInt(strs[0]) * 60000; break; } } catch (NumberFormatException e) { return 0; } return ticks; } public static String tickToText(long tick) { String str = ""; if(tick > 5900000) str += "99:"; else str += String.format("%02d", (int) ((double) tick / 60000d)) + ":"; tick -= (int) ((double) tick / 60000d) * 60000; str += String.format("%02d", (int) ((double) tick / 1000d)) + "."; tick -= (int) ((double) tick / 1000d) * 1000; str += String.format("%03d", tick); return str; } public static String formatTime(String str) { return tickToText(textToTick(str)); } public static int transformZoom(long n, double zoom) { return (int) ((double) n / (double) PatternJPanel.ZOOM_MULTIPLIER * zoom); } }