检查对象的类是否为日期的条件
我想检查一个对象是否是一个类,如果是一个日期则进行一些格式化。如何设置 if
条件?
<table align="center" class="data_extract vert_scroll_table" >
<tr>
<c:forEach var="heading" items="${results.headings}">
<th class="data_extract">${heading}</th>
</c:forEach>
</tr>
<c:forEach var="row" items="${results.data}">
<tr>
<c:forEach var="cell" items="${row}" varStatus="rowStatus">
<td class="data_extract">
<c:choose>
<c:when test="${results.types[rowStatus.index].array}">
<c:set var="comma" value="," />
<c:forEach var="elem" items="${cell}" varStatus="cellStatus">
<c:set var="myVar" value="${cellStatus.first ? '' : myVar} ${elem} ${cellStatus.last ? '' : comma}" />
</c:forEach>
<span class="mouseover_text" title="${myVar}">${myVar}</span>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${results.types[rowStatus.index].componentType.class.name eq 'java.sql.Timestamp'}">
<fmt:formatDate value="${cell}" pattern="${date_pattern}" />
</c:when>
<c:otherwise>
${cell}
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
</td>
</c:forEach>
</tr>
</c:forEach>
</table>
I want to check if an object is a class and do some formatting if it is a date. How would I set the if
condtion?
<table align="center" class="data_extract vert_scroll_table" >
<tr>
<c:forEach var="heading" items="${results.headings}">
<th class="data_extract">${heading}</th>
</c:forEach>
</tr>
<c:forEach var="row" items="${results.data}">
<tr>
<c:forEach var="cell" items="${row}" varStatus="rowStatus">
<td class="data_extract">
<c:choose>
<c:when test="${results.types[rowStatus.index].array}">
<c:set var="comma" value="," />
<c:forEach var="elem" items="${cell}" varStatus="cellStatus">
<c:set var="myVar" value="${cellStatus.first ? '' : myVar} ${elem} ${cellStatus.last ? '' : comma}" />
</c:forEach>
<span class="mouseover_text" title="${myVar}">${myVar}</span>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${results.types[rowStatus.index].componentType.class.name eq 'java.sql.Timestamp'}">
<fmt:formatDate value="${cell}" pattern="${date_pattern}" />
</c:when>
<c:otherwise>
${cell}
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
</td>
</c:forEach>
</tr>
</c:forEach>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSTL 将调用标准 setter getter,因此您可以使用 getClass() 和 getName() 方法
JSTL will invoke standard setter getters so you can use getClass() and getName() method