Here you can find the source of converTime(long timestamp, String[] timeLabels)
public static String converTime(long timestamp, String[] timeLabels)
//package com.java2s; public class Main { public static String converTime(long timestamp, String[] timeLabels) { long currentSeconds = System.currentTimeMillis() / 1000; long timeGap = currentSeconds - timestamp; String timeStr = null;/*from w w w . java 2 s . com*/ if (timeGap > 24 * 60 * 60) { timeStr = timeGap / (24 * 60 * 60) + timeLabels[0]; } else if (timeGap > 60 * 60) { timeStr = timeGap / (60 * 60) + timeLabels[1]; } else if (timeGap > 60) { timeStr = timeGap / 60 + timeLabels[2]; } else { timeStr = timeLabels[3]; } return timeStr; } }