因為我數據庫中的一個字段是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 的格式書寫