yujian
2019-05-30 46a9e2d5bb4563b3a8194b7655ffcf4af5f6e19f
动态时间修正
1个文件已修改
17 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicController.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/DynamicController.java
@@ -3,6 +3,7 @@
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -184,11 +185,23 @@
                String desc = "";
                if (value != null) {
                    // 判断是否是同一天
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(value);
                    int y1 = calendar.get(Calendar.YEAR);//获取年份
                    int d1 = calendar.get(Calendar.DAY_OF_YEAR);//获取年中第几天
                    Date nowDate = new Date();
                    Calendar calendar2 = Calendar.getInstance();
                    calendar2.setTime(nowDate);
                    int y2 = calendar2.get(Calendar.YEAR);//获取年份
                    int d2 = calendar2.get(Calendar.DAY_OF_YEAR);//获取年中第几天
                    long old = value.getTime();
                    long now = System.currentTimeMillis();
                    long now = nowDate.getTime();
                    long oldDay = old / (1000 * 60 * 60 * 24L);
                    long nowDay = now / (1000 * 60 * 60 * 24L);
                    if (oldDay == nowDay) {// 同一天
                    if (y1 == y2 && d1 == d2) {//判断是不是同一年的同一天
                        long cha = now - old;
                        if (cha < 1000 * 60 * 2L)
                            desc = "刚刚";