无法从jsp格式将日期时间传递给google appengine

问题描述 投票:0回答:1

我正在尝试保存日期和时间,以使其从用户在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
1个回答
0
投票

我不清楚您打算如何在前端花费时间,但是您正在将无效的时间格式传递给Java。

© www.soinside.com 2019 - 2024. All rights reserved.