jstl format date
使用fmt函数需在jsp中引入
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatDate value="${item.expDate}" pattern="yyyy-MM-dd"/>
报java.lang.IllegalArgumentException: Cannot convert 20131125 of type class java.lang.String to class java.util.Date
异常 因为${item.expDate}取出来是String类型,无法转换为Date类型
如下将能正常输出
<fmt:formatDate value="<%=new Date() %>" pattern="yyyy-MM-dd"/>
解决办法是,可先将String解析为Date 然后再格式化Date 。
<fmt:parseDate value="${item.expDate}" var="yearMonth" pattern="yyyy-MM-dd"/>
<fmt:formatDate value="${yearMonth}" pattern="yyyy-MM" /><!-- 这里的value只能是date类型-->
jstl format date的更多相关文章
- 【java】Date与String之间的转换及Calendar类:java.text.SimpleDateFormat、public Date parse(String source) throws ParseException和public final String format(Date date)
package 日期日历类; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util. ...
- Ext.util.Format.date与Ext.Date.format区别, 转换时间戳
在Extjs中装时间戳使用如下两种都可以: Ext.util.Format.date(time,'U'); Ext.Date.format(time, 'U'); 为了找到它们的区别,查看源代码,以E ...
- Ext.util.Format.date 时间格式的设置与转换
Ext.util.Format.date 如下这段简单的代码: var d = new Date(value.time); var s = Ext.util.Format.date(d, 'Y-m- ...
- jstl 处理Date 时间
1.引入 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> < ...
- [React Intl] Format Date and Time Using react-intl FormattedDate and FormattedTime
Using the react-intl FormattedDate and FormattedTime components, we’ll render a JavaScript Date into ...
- 杂记-格式化Date默认格式,日期加一天,jstl判断字符类型,ajax模拟from表单后台跳转页面,jstl访问数据库并在页面显示
1.格式化Date默认格式 String str="Sun Oct 08 22:36:45 CST 2017"; SimpleDateFormat sdf = new Simple ...
- 使用date类和format类对系统当前时间进行格式化显示
一:Date------------String 代码1:(代码二对显示出来的时间格式进行优化) package DateDemo; import java.text.SimpleDateFormat ...
- Java 8 Date Time API Example Tutorial – LocalDate, Instant, LocalDateTime, Parse and Format
参考 Java 8 Date and Time API is one of the most sought after change for developers. Java has been mis ...
- Cannot format given Object as a Date
这个小错挺有意思的,记录一下 导出Excel的时候,同事直接用 format …… 前提:数据库中该字段是 Timestamp ---- 2016-06-20 22:49:02.967 写个测试说明一 ...
随机推荐
- MapReduce 编程模型概述
MapReduce 编程模型给出了其分布式编程方法,共分 5 个步骤:1) 迭代(iteration).遍历输入数据, 并将之解析成 key/value 对.2) 将输入 key/value 对映射( ...
- MySQL服务器安装完之后如何调节性能
原文作者: Peter Zaitsev原文来源: http://www.mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server ...
- (转)D3d9c的固定渲染管道(fixed function pipeline)与可编程管道(programmable function pipeline)的异同点
转自:http://blog.csdn.net/tspatial_thunder/article/details/5937701 现在的游戏图形部分越来多依靠GPU来渲染绘制.说起GPU先说着色器,着 ...
- GTID数据库备份
rhel6系统中,mysql 5.6复制新特性下主从复制配置[基于GTID] 1.mysql5.6在复制方面的新特性: (1).支持多线程复制:事实上是针对每个database开启相应的独立线程,即每 ...
- Pureftp SSL/TLS配置
一.准备 & 安装 启用 Pure-FTPd SSL/TLS 连接方式在安装时需要检查以下两项: 1.系统中是否已经安装了 openssl 和 openssl-devel 包? 2.在编译 P ...
- ShareSDK for Android 2.3.10已经公布
ShareSDK for Android 2.3.10已经公布,本次更新内容包含: 1.加入自己定义分享标签功能 新版本号SDK下载页面地址: http://share.sharesdk.cn/Dow ...
- js冒泡法和数组转换成字符串
js代码: window.onload = function(){ var mian = document.getElementById( "mian" ); var mian1 ...
- iOS buttonWithType:101 苹果私有api
无意中发现,有人创建UIButton这样写 UIButton *previousButton = [UIButtonbuttonWithType:101]; 一看原来是私有api UIButton * ...
- 彻底告别加解密模块代码拷贝-JCE核心Cpiher详解
前提 javax.crypto.Cipher,翻译为密码,其实叫做密码器更加合适.Cipher是JCA(Java Cryptographic Extension,Java加密扩展)的核心,提供基于多种 ...
- java线程-synchronized实现可见性代码
以下是一个普通线程代码: package com.Sychronized; public class SychronizedDemo { //共享变量 private boolean ready=fa ...