我有两个日期,fromDate和toDate。
比如说,txtEffectiveDate是26/02/2013,而txtInactiveDate是28/02/2013,我需要在jsp中将我的标题设为26/02 27/02 and 28/02
。我编写了一个util函数,它返回天数的差异。这就是我迄今取得的成就。
<table border="0" cellpadding="4" cellspacing="1">
<tr>
<td width="100" class="boxBorderHeader141">Service NO.</td>
<% long diff= 0 ;
diff = DateUtil.getDifference(DateUtil.toUtilDate(request.getAttribute("txtEffectiveDate").toString()), DateUtil.toUtilDate(request.getAttribute("txtInactiveDate").toString()));
%>
<td width="100" class="boxBorderHeader141"><bean:write name="servicesForm" property="txtEffectiveDate" /></td>
<td width="100" class="boxBorderHeader141">Departure Time</td>
<td width="100" class="boxBorderHeader141">Depot Code</td>
<td width="100" class="boxBorderHeader141">Service Category</td>
<td width="100" class="boxBorderHeader141">Service Name</td>
<td> </td>
</tr>
</table>
日期应在服务号码和出发时间之间重复?
感谢任何帮助。
由于
答案 0 :(得分:0)
在您的scriptlet中,计算更多日期
您的代码
long diff= 0 ;
diff = DateUtil.getDifference(DateUtil.toUtilDate(request.getAttribute("txtEffectiveDate").toString()), DateUtil.toUtilDate(request.getAttribute("txtInactiveDate").toString()));
<强>扩展强>
Calendar cal = Calendar.getInstance();
for(int i=0; i < diff; i ++){
cal.setTime(DateUtil.toUtilDate(request.getAttribute("txtEffectiveDate").toString()));
cal.add(Calendar.DATE, i + 1);
java.util.Date newDate = cal.getDate();
// Display that new date as column
}