【发布时间】:2020-05-13 09:12:11
【问题描述】:
我正在尝试通过用户从在 JSP 中创建并由 java servlet 接收的前端保存日期和时间。 以下是我的 JSP 的代码:
<form role="form" action="/abc" method="post">
<div class="form-group">
<div class="input-group">
<input type="hidden" name="div_bvg" type="number" class="form-control" value="0" required/>
</div>
</div>
Enter the Details:
<div class="input-group">
<span class="input-group-addon">End Date</span>
<input name="div_enddate" type="datetime-local" class="form-control" required/>
</div>
</div>
<a href="/dashboard" class="btn btn-default">Cancel</a>
<button type="submit" class="btn btn-success">Save</button>
</form>
以下是通过我的servlet接收
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
String sdate = request.getParameter("div_enddate").trim();
DateTime enddate = new DateTime(edate);
Entity election = new Entity("example");
election.setProperty("EndTime", enddate);
Transaction txn = datastore.beginTransaction();
datastore.put(txn,election);
txn.commit();
if (txn.isActive()) { //if trnasaction is still active (which means not committed properly then it rollbacks)
txn.rollback();
}
以下是我提交时遇到的错误
java.lang.NumberFormatException: Invalid date/time format: 2020-01-01T01:00
【问题讨论】:
标签: jsp google-app-engine servlets