HTML时间选择器 controller中时间格式的设定

HTML

<div class="form-group">
                            <label class="">时间</label>:
                            <select id="type" name="type" class="form-control" onchange="factoryElectric.timeSelection()">
                                <option value ="1" th:selected="${type==1 }">当天</option>
                                <option value ="2" th:selected="${type==2}">当月</option>
                                <option value ="3" th:selected="${type==3}">自定义</option>
                            </select>
                        </div>
                        <div id="timeDiv" class="form-group" style="display: none">
                            <label class="search-label">采集时间 </label>: 从
                            <input th:value="${#dates.format(startTime,'yyyy-MM-dd HH:mm:ss')}" type="text" id="startTime" name="startTime" class="form-control wdateTime dateRange" datefmt="yyyy-MM-dd HH:mm:ss" />
                            <label class="search-label">至</label>:
                            <input th:value="${#dates.format(endTime,'yyyy-MM-dd HH:mm:ss')}" type="text" id="endTime" name="endTime" class="form-control wdateTime dateRange" datefmt="yyyy-MM-dd HH:mm:ss" />
                        </div>

JS

 timeSelection:function(){
            var type = $("#type").val();
            if(type == 1 ||type==2){
                $("#timeDiv").attr("style","display:none;");
            }else{
                $("#timeDiv").attr("style","display:;");
            }
        },
@InitBinder
	protected void initBinder(WebDataBinder binder) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
	}

格式设置

猜你喜欢

转载自blog.csdn.net/qq_39091546/article/details/106722075