写bug的小杨

导航

时间格式处理

sql时间处理:

https://blog.csdn.net/the_it_world/article/details/100743945

改成精确到天

DATE_FORMAT(app_last_time,'%Y-%m-%d')

 

--------------------------------------------------------------------------------------------------------

创建时间精确到天

SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
bartDateFormat.format(date);

  

昨天

public static String getLastDay(String time){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        Date date=null;
        try {
            date = sdf.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        calendar.setTime(date);
        int day=calendar.get(Calendar.DATE);
        //                      此处修改为+1则是获取后一天
        calendar.set(Calendar.DATE,day-1);

        String lastDay = sdf.format(calendar.getTime());
        return lastDay;
    }

  

posted on 2020-09-22 14:44  迷途的小狗  阅读(137)  评论(0编辑  收藏  举报