/**
* 将一个十位数字的时间戳转换成时间字符串
*
*/
public static String convertTimeToFormat(long timeStamp) {
long curTime =System.currentTimeMillis() / (long) 1000 ;
long time = curTime - timeStamp;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
String date = sdf.format(timeStamp * 1000);
Log.i("info","date打印3"+date);
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String date1 = sdf.format(curTime * 1000);
Log.i("info","date打印4"+date1);
if (time < 60 && time >= 0) {
return "刚刚" +" "+date;
} else if (time >= 60 && time < 3600) {
return time / 60 + "分钟前" +" "+date;
} else if (time >= 3600 && time < 3600 * 24) {
return time / 3600 + "小时前" +" "+date;
} else if (time >= 3600 * 24 && time < 3600 * 24 * 30) {
return time / 3600 / 24 + "天前" +" "+date;
} else if (time >= 3600 * 24 * 30 && time < 3600 * 24 * 30 * 12) {
return time / 3600 / 24 / 30 + "个月前" +" "+date;
} else if (time >= 3600 * 24 * 30 * 12) {
return time / 3600 / 24 / 30 / 12 + "年前" +" "+date;
} else {
return "刚刚";
}
}
* 将一个十位数字的时间戳转换成时间字符串
*
*/
public static String convertTimeToFormat(long timeStamp) {
long curTime =System.currentTimeMillis() / (long) 1000 ;
long time = curTime - timeStamp;
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
String date = sdf.format(timeStamp * 1000);
Log.i("info","date打印3"+date);
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String date1 = sdf.format(curTime * 1000);
Log.i("info","date打印4"+date1);
if (time < 60 && time >= 0) {
return "刚刚" +" "+date;
} else if (time >= 60 && time < 3600) {
return time / 60 + "分钟前" +" "+date;
} else if (time >= 3600 && time < 3600 * 24) {
return time / 3600 + "小时前" +" "+date;
} else if (time >= 3600 * 24 && time < 3600 * 24 * 30) {
return time / 3600 / 24 + "天前" +" "+date;
} else if (time >= 3600 * 24 * 30 && time < 3600 * 24 * 30 * 12) {
return time / 3600 / 24 / 30 + "个月前" +" "+date;
} else if (time >= 3600 * 24 * 30 * 12) {
return time / 3600 / 24 / 30 / 12 + "年前" +" "+date;
} else {
return "刚刚";
}
}