Here you can find the source of formatTimeInfo(long time)
Parameter | Description |
---|---|
ms | size of file |
public static String formatTimeInfo(long time)
//package com.java2s; /*/*from w ww. j av a 2s . c o m*/ * Copyright (C) 2013-2015 E-Spring Tran * * https://espringtran.com * * This program 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 3 of the License, or * (at your option) any later version. * * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Get size info * * @param ms * size of file * @return */ public static String formatTimeInfo(long time) { String info = ""; long ms = (long) time; int i = 1000; int value = (int) ms % i; info = value + " millisecond(s)"; ms /= i; if (ms > 0) { i = 60; value = (int) ms % i; info = value + " second(s) " + info; ms /= i; } if (ms > 0) { i = 60; value = (int) ms % i; info = value + " minute(s) " + info; ms /= i; } if (ms > 0) { i = 24; value = (int) ms % i; info = value + " hour(s) " + info; ms /= i; } if (ms > 0) { i = 30; value = (int) ms % i; info = value + " day(s) " + info; ms /= i; } if (ms > 0) { i = 12; value = (int) ms % i; info = value + " month(s) " + info; ms /= i; } if (ms > 0) { info = ms + " year(s) " + info; } return info; } }