/**
* 计算该时间离当前时间的差距
* @param time 格式为:yyyy-MM-dd HH:mm:ss
* @return
*/
public static String getShortTime(String time) {
Date date = getDateByString(time);
return getShortTime(date);
} public static String getShortTime(Date date) {
String shortstring = null;
long now = Calendar.getInstance().getTimeInMillis();
if(date == null) return shortstring;
long deltime = (now - date.getTime())/;
if(deltime > ***) {
shortstring = (int)(deltime/(***)) + "年前";
} else if(deltime > ***) {
shortstring = (int)(deltime/(***)) + "周前";
} else if(deltime > **) {
shortstring = (int)(deltime/(**)) + "天前";
} else if(deltime > *) {
shortstring = (int)(deltime/(*)) + "小时前";
} else if(deltime > ) {
shortstring = (int)(deltime/()) + "分钟前";
} else if(deltime > ) {
shortstring = deltime + "秒前";
} else {
shortstring = "刚刚";
}
return shortstring;
}