我正在使用 Jsp。我想根据当前日期和时间显示 future 的日期和时间。
解释。客户在网站和 confirmation page
上购买商品他们看到他们订购的日期。我用 <input class="input_ship" style="border:none; background:papayawhip; text-align:center;" name="OrderDate" value="<%= new java.util.Date()%>" readonly>
向用户显示当前日期。
现在我希望用户知道他的订单何时发货,方法是计算一个简单的数学方程式 (current date + X days later
) 返回 future 的某个日期。我将如何着手做这个后端?
最佳答案
将日期值转换为日期
,类似于:
var currentdate = new Date(document.querySelector('input.input_ship').value);
现在您可以使用以下方法提前 5 天设置日期:
currentdate.setDate(currentdate.getDate()+5)
关于java - 如何通过数学计算显示 future 的日期和时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30359643/