jsp页面时间显示年月日(decode用法)

有时候页面显示时间需要显示年月日,我这介绍两种转换格式的方法(针对oracle)。

1、sql语句直接转换

select to_char(t.time,'yyyy')||decode(t.time,null,'','年')||to_char(t.time,'mm')||decode(t.time,null,'','月')||to_char(t.time,'dd')||decode(t.time,null,'','日') from table t; 

2、jstl标签

<fmt:formatDate value="${data}" pattern="yyyy年MM月dd日"/>

猜你喜欢

转载自cao-dong-yang.iteye.com/blog/2363439