Here you can find the source of formatTimePeriod(long timestamp)
public static String formatTimePeriod(long timestamp)
//package com.java2s; //License from project: Open Source License public class Main { public static String formatTimePeriod(long timestamp) { if (timestamp < 1000) return timestamp + " ms"; if (timestamp < 60 * 1000) return (timestamp / 1000) + " sec"; if (timestamp < 60 * 60 * 1000) return (timestamp / (1000 * 60)) + " min"; if (timestamp < 24 * 60 * 60 * 1000) return (timestamp / (1000 * 60 * 60)) + " h"; return (timestamp / (24 * 1000 * 60 * 60)) + " day"; }// w w w. jav a 2 s .c o m }