public String getStandardDate(int dateTime) {
StringBuffer sb = new StringBuffer();
long t = Long.parseLong(String.valueOf(dateTime));
long time = System.currentTimeMillis() - (t * 1000);
long mill = (long) Math.ceil(time / 1000);//秒前
long minute = (long) Math.ceil(time / 60 / 1000.0f);// 分钟前
long hour = (long) Math.ceil(time / 60 / 60 / 1000.0f);// 小时
long day = (long) Math.ceil(time / 24 / 60 / 60 / 1000.0f);// 天前
long month = (long) Math.ceil(time / 30 / 24 / 60 / 60 / 1000.0f);// 月前
long year = (long) Math.ceil(time / 12 / 30 / 24 / 60 / 60 / 1000.0f);// 年前
Calendar cal = Calendar.getInstance();
long showYear = cal.get(Calendar.YEAR);
long showMonth = cal.get(Calendar.MONTH);
long showDay = cal.get(Calendar.DATE);
long showHour = cal.get(Calendar.HOUR_OF_DAY);
long showMint = cal.get(Calendar.MINUTE);
if (month - 1 > 0) {
if (month >= 12) {
sb.append(showYear + "." + showMonth + "." + showDay + " " + showHour + ":" + showMint);
} else {
sb.append(month + "个月");
}
} else if (day - 1 > 0) {
if (day >= 30) {
sb.append("1个月");
} else {
sb.append(day + "天");
}
} else if (hour - 1 > 0) {
if (hour >= 24) {
sb.append("1天");
} else {
sb.append(hour + "个小时");
}
} else if (minute - 1 > 0) {
if (minute == 60) {
sb.append("1个小时");
} else {
sb.append(minute + "分钟");
}
} else if (mill - 1 > 0) {
if (mill == 60) {
sb.append("1分钟");
} else {
sb.append(mill + "秒");
}
} else {
sb.append("刚刚");
}
if (month <= 12 && !sb.toString().equals("刚刚")) {
sb.append("前");
}
return sb.toString();
}