淘先锋技术网

首页 1 2 3 4 5 6 7

SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");

String createDate = null;SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String createTime = sdf2.format(gcCommentList.get(i).getCreateTime());Date date = null;try { date = sdf2.parse(createTime); long differenceValue = new Date().getTime() - date.getTime(); if(differenceValue < 3600000){ if((differenceValue / 1000 / 60 )==0){ createDate = "刚刚"; }else{ createDate = (differenceValue / 1000 / 60 ) + "分钟前"; } }else if(differenceValue > 3600000){ if(differenceValue < 86400000){ createDate = (differenceValue / 1000 / 60 / 60 ) + "小时前"; }else{ createDate = sdf.format(gcCommentList.get(i).getCreateTime()); } } paramMap.put("createTime", createDate);} catch (ParseException e) { e.printStackTrace();}

来源:https://www.cnblogs.com/weimengduzun/p/9558523.html