Here you can find the source of timestampToPrettyString(long ts)
Parameter | Description |
---|---|
ts | a parameter |
public static String timestampToPrettyString(long ts)
//package com.java2s; /*//w ww . j a v a 2s. c o m * Copyright (c) 2001-2011 Convertigo SA. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero 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/>. * * $URL$ * $Author$ * $Revision$ * $Date$ */ public class Main { /** * Format ts from "0m00" to "59m59", then "1h00" to "xxxxh59" * * @param ts * @return */ public static String timestampToPrettyString(long ts) { long s = (ts /= 1000) % 60; long m = (ts /= 60) % 60; long h = ts / 60; return (h > 0 ? (h + "h") : "") + ((m < 10 && h > 0) ? "0" : "") + m + (h == 0 ? ("m" + ((s < 10) ? "0" : "") + s) : ""); } }