将Date格式日期在前端页面显示

将Date格式日期在前端页面显示需要在代码中转换为String形式

List<IndustryBean> list=industryService.getByletterOrDateList(industryBean);
        for (int i = 0; i < list.size(); i++) {
            Date date = list.get(i).getCreateDate();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String rightDate = sdf.format(date);
            list.get(i).setRightDate(rightDate);
        }
        return JSONObject.toJSONString(list);

 String.ForMat 将对象的值转为基于指定格式的字符串 并将其插入到指定字符串

例String title = String.format("%s-%s月工作记录",userBean.getName(),mouth); xx-01月工作记录

posted @ 2016-02-17 10:20  idiot_ioi  阅读(6381)  评论(0编辑  收藏  举报