Here you can find the source of formatTS(long duration)
public static String formatTS(long duration)
//package com.java2s; /*//from ww w.j a va2s . c om * Copyright (C) 2011 Sony Ericsson Mobile Communications AB * Copyright (C) 2012-2013 Sony Mobile Communications AB * * This file is part of ChkBugReport. * * ChkBugReport is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * ChkBugReport is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ChkBugReport. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static String formatTS(long duration) { StringBuffer sb = new StringBuffer(); sb.insert(0, "ms"); sb.insert(0, duration % 1000); duration /= 1000; if (duration > 0) { sb.insert(0, "s"); sb.insert(0, duration % 60); duration /= 60; } if (duration > 0) { sb.insert(0, "m"); sb.insert(0, duration % 60); duration /= 60; } if (duration > 0) { sb.insert(0, "h"); sb.insert(0, duration % 24); duration /= 24; } if (duration > 0) { sb.insert(0, "d"); sb.insert(0, duration); } return sb.toString(); } }