因为我数据库中的一个字段是DateTime类型,用EL表达式输出到界面的时候是 1985-12-16 00:00:00.0 。EL表达式:${userBirthday}
问题是:
我想让它输出的是 1985-12-16 .用EL表达式怎么写?
1.<%@tablib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
上面的 uri 根据你的实际情况定。
${fn:substring("你要截取的字符串"),beginIndex,endIndex}
2.可以采用 JSTL 的 fmt 进行日期格式化显示
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatDate value="${userBirthday}" pattern="yyyy-MM-dd">
pattern 完全按照 SimpleDateFormat 的格式书写
此文章由 http://www.ositren.com 收集整理 ,地址为:
http://www.ositren.com/htmls/68720.html