下载地址:https://download.csdn.net/download/qzc2017/10878539
<input type="text" name="online" id="datepicker">
<style>
.date input{
width: 140px;
height: 32px;
border:solid 1px #cccccc;
padding: 0 0 0 8px;
background: url("img/date.jpg") right no-repeat;
margin-top: 50px;
margin-right: 12px;
margin-left: 8px;
}
.date_text{
margin-top: 50px;
line-height: 32px;
}
</style>
<script>
var picker = new Pikaday(
{
field: document.getElementById('datepicker'),
firstDay: 1,
minDate: new Date('1980-01-01'),
maxDate: new Date('2099-12-31'),
yearRange: [1980,2099]
});
</script>
dateObj.online1 = $("#datepicker").val();
// 上线日期
String online1 = request.getParameter("online1");
if (StringUtil.isNotEmpty(online1)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = sdf.parse(online1);
} catch (ParseException e) {
e.printStackTrace();
}
Long online = date.getTime(); //时间字符串->Long
platformInfo.setOnline(online);
}
private Long online; bean属性 数据库保存的是 bigint(13) 13位时间戳
二、WdatePicker
<div class="form-group">
<label class="col-sm-2 control-label laber_from" for="evaluationtime1">评价时间</label>
<div class="col-sm-3">
<input type="text" class="Wdate" id="evaluationtime1" name="evaluationtime1"
value="${dateUtils.formatDate(platformEvaluate.evaluationtime)}" style="width: 180px;height: 30px;"
onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
<span id="publicTimeError" style="color:red"></span>
</div>
</div>
若需只选择年月日
onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})
String evaluationtime1 = request.getParameter("evaluationtime1"); if (evaluationtime1 != null || !"".equals(evaluationtime1.trim())) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = sdf.parse(evaluationtime1); Long evaluationtime = date.getTime(); platformEvaluate.setEvaluationtime(evaluationtime); }