部分日期格式

こ雲淡風輕ζ 提交于 2019-12-03 10:49:22
thymeleaf的update操作  页面上时间格式${#dates.format(contactinvoicee.dateofmakingorder,'yyyy-MM-dd')}js中对日期格式操作
$("#reporttime").val(moment().format("YYYY-MM-DD"));function 中
return moment(value).format('YYYY-MM-DD');实体类中  在get方法上加注解
@JsonFormat(pattern = "yyyy-MM-dd")public Date getBegin() {   return begin;}设置 date日期只能是明天 如果直接newdate上+1会出现32号  html中的input 的 class删掉layer-date属性 
var tomorrow = new Date();tomorrow.setTime(tomorrow.getTime() + 24*60*60*1000);var tomorrowStr = tomorrow.getFullYear()+"-"+(tomorrow.getMonth()+1)+"-"+tomorrow.getDate(); laydate.render({    elem: '#yuyuedate'    ,min: tomorrowStr});js 中 给select 绑定前后几年 和循环所有月份
var now = new Date();var selmonth=$("#month");var selyear = $("#year");var year = now.getFullYear()-2;                        //获取当前年份for (var i = 0; i < 6; i++) {    var option = $("<option>").val(year).text(year);    //给option添加value值与文本值    selyear.append(option);                            //添加到select下    year = year+1;                                    //年份+1,再添加一次};selyear.find("option").each(function () {    var thisyaer=now.getFullYear();    if($(this).val()==thisyaer){        $(this).attr("selected",true);    }});for(var j=1;j<=12;j++){    var opt=$("<option>").val(j).text(j+"月");    selmonth.append(opt)}
在update时的 回显判断
selyear.find("option").each(function () {    var thisyaer =$("#yearflag").val()    if ($(this).val() == thisyaer) {        $(this).attr("selected", true);    }});thymeleaf  回显   这是controller里ArrayList集合
<select name="month" id="month"  class="form-control">    <option th:each="list,monthStat:${months}"            th:text="${list.yue}"            th:value="${monthStat.index}+1"            th:field="${goyixingreport.month}"></option></select>


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!