Here you can find the source of timeAgo(long aTime)
public static TimeContainer timeAgo(long aTime)
//License from project: Apache License import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main{ public static TimeContainer timeAgo(long aTime) { TimeContainer result = null;//from w ww .j a v a2 s. c om long currentTime = System.currentTimeMillis(); long delta = currentTime - aTime; if (delta > 0) { result = new TimeContainer(); if (delta / (1000 * 60 * 60 * 24 * 30 * 12) > 0) { result.count = (int) (delta / (1000 * 60 * 60 * 24 * 30 * 12)); result.time = Time.YEAR; } else if (result.count == 0 && delta / (1000 * 60 * 60 * 24 * 30) > 0) { result.count = (int) (delta / (1000 * 60 * 60 * 24 * 30)); result.time = Time.MONTH; } else if (result.count == 0 && delta / (1000 * 60 * 60 * 24) > 0) { result.count = (int) (delta / (1000 * 60 * 60 * 24)); result.time = Time.DAY; } else if (result.count == 0 && delta / (1000 * 60 * 60) > 0) { result.count = (int) (delta / (1000 * 60 * 60)); result.time = Time.HOUR; } else if (result.count == 0 && delta / (1000 * 60) > 0) { result.count = (int) (delta / (1000 * 60)); result.time = Time.MIN; } else if (result.count == 0 && delta / (1000) > 0) { result.count = (int) (delta / 1000); result.time = Time.SEC; } } return result; } }