初始化日期控件
$(document).ready(function() {
......
$('#shouquanstart').datetimepicker({
format: "YYYY-MM-DD HH:mm:ss",
defaultDate:new Date()
});
......
});
页面添加日期控件
<div class="form-group">
<label class="col-sm-1 control-label">有效开始时间:</label>
<div class="col-sm-5">
<p class="input-group">
<div class='input-group form_datetime' id='shouquanstart'>
<input id="onsiteptw.ptwnum" name="onsiteptw.onsiteptw4gzxksqList[0].shouquanstart" type="text" maxlength="20" class="form-control"
value="<fmt:formatDate value="${onsiteptwProcess.onsiteptw.onsiteptw4gzxksqList[0].shouquanstart}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</p>
</div>
</div>
后台对象
private Date shouquanstart; // 开始时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ExcelField(title="开始时间", align=2, sort=12)
public Date getShouquanstart() {
return shouquanstart;
}
public void setShouquanstart(Date shouquanstart) {
this.shouquanstart = shouquanstart;
}
备注
JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")必须和页面的 pattern="yyyy-MM-dd HH:mm:ss"/>"/>一致