public static String dateDifferenceDesc(Date now, Date early) { String res = ""; if (null != now && null != early) { Long preTime = now.getTime() - early.getTime(); if (preTime < 60000L) { res = "1分钟前"; } else if (preTime < 3600000L) { res = (preTime / 60000L) + "分钟前"; } else if (preTime < 86400000L) { res = (preTime / 3600000L) + "小时前"; } else if (preTime < 172800000L) { res = "昨天"; } else if (preTime < 259200000L) { res = "前天"; } else if (preTime < 31536000000L) { res = (preTime / 86400000L) + "天前"; } else { res = (preTime / 31536000000L) + "年前"; } } return res; }