// 转为 n秒前 n分钟前 n小时前 日期
public static String dataLongToSNS(long time,String format){
long now = System.currentTimeMillis();
long diff = now -time;
diff = diff/1000;// 秒
if(diff<0){
return dateLongToString(time,format);
}
if(diff<30){ // 30秒
return "刚刚";
}
if(diff<60){
return String.format("%s秒前", diff);
}
if(diff<3600){
return String.format("%s分钟前", diff/60);
}
//获取今天凌晨时间
long todayStart = DateUtils.getTodayStartTime();
if(time>=todayStart){// 今天
return String.format("%s小时前", diff/3600);
}
if(time<todayStart && time >= todayStart-86400000){
return "昨天 " + dateLongToString(time, "HH:mm");
}
return dateLongToString(time,format);
}