JSP Standard Tag Libraries
Formatting and Internationalization
Two form input parameters, 'date' and 'isoDate', are URL-encoded in the link leading to this page. 'isoDate' is formatted according to the ISO8601 standard.
Formatting of numbers and dates is based on the browser's locale setting. Formatting will change if you switch the default language setting from English to French or German, for example. (The browser needs to be restarted, too.)

Library import and parameter capturing:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

<fmt:parseDate value="${param.date}" var="date" pattern="yyyy/MM/dd:HH:mm:ss>
<fmt:parseDate value="${param.isoDate}" var="isoDate" pattern="yyyyMMdd'T'HHmmss">

The input parameters must match the patterns, or the JSP will thrown an exception. This page does no error handling.

Input parameters:
Date:    2004/04/01:13:30:00  Java format: Thu Apr 01 13:30:00 CST 2004
isoDate: 20040531T235959      Java format: Mon May 31 23:59:59 CDT 2004

Dates
Tag Output
Attribute: value; required. Tag has no body.
<fmt:formatDate value="${date}" type="both"/>

2004-4-1 13:30:00 
<fmt:formatDate value="${isoDate}" type="both"/>

2004-5-31 23:59:59 
Attribute: type; optional. Indicates what to print: date, time, or both.
<fmt:formatDate value="${date}" type="date"/>

2004-4-1 
<fmt:formatDate value="${isoDate}" type="time"/>

23:59:59 
Attribute: dateStyle; optional. Varies the date format.
<fmt:formatDate value="${isoDate}" type="date" dateStyle="default"/>

2004-5-31 
<fmt:formatDate value="${isoDate}" type="date" dateStyle="short"/>

04-5-31 
<fmt:formatDate value="${isoDate}" type="date" dateStyle="medium"/>

2004-5-31 
<fmt:formatDate value="${isoDate}" type="date" dateStyle="long"/>

2004年5月31日 
<fmt:formatDate value="${isoDate}" type="date" dateStyle="full"/>

2004年5月31日 星期一 
Attribute: timeStyle; optional. Varies the time format.
<fmt:formatDate value="${isoDate}" type="time" timeStyle="default"/>

23:59:59 
<fmt:formatDate value="${isoDate}" type="time" timeStyle="short"/>

下午11:59 
<fmt:formatDate value="${isoDate}" type="time" timeStyle="medium"/>

23:59:59 
<fmt:formatDate value="${isoDate}" type="time" timeStyle="long"/>

下午11时59分59秒 
<fmt:formatDate value="${isoDate}" type="time" timeStyle="full"/>

下午11时59分59秒 CDT 
Attribute: pattern; optional. Inidcates date/time custom patterns.
<fmt:formatDate value="${date}" type="both" pattern="EEEE, MMMM d, yyyy HH:mm:ss Z"/>

星期四, 四月 1, 2004 13:30:00 -0600 
<fmt:formatDate value="${isoDate}" type="both" pattern="d MMM yy, h:m:s a zzzz/>

JSTL日期格式化用法的更多相关文章

  1. Freemarker 内置函数 数字、字符串、日期格式化用法介绍

    在用FreeMarker过程中,感觉FreeMarker的字符串,日期,集合等处理能力还是很强大的,上网搜了一些资料,整理如下,以便能帮助大家更熟练的应用Freemarker完成项目开发. 一.Seq ...

  2. Asp.net中具体的日期格式化用法

    1.绑定时格式化日期方法: <ASP:BOUNDCOLUMN DATAFIELD= "JoinTime " DATAFORMATSTRING= "{0:yyyy-M ...

  3. JSP中利用JSTL标签对日期格式化

    数据库:Mysql 开发语言:JAVA 页面类型:JSP 对Mysql中的日期类型格式化,在JSP中,如何办呢,很多人说在JAVA后台去日期格式化,无奈了,于是找到了比较靠谱的答案 需要先引入JSTL ...

  4. SQLServer日期格式化

    0   或   100   (*)     默认值   mon   dd   yyyy   hh:miAM(或   PM)       1   101   美国   mm/dd/yyyy       ...

  5. sql日期格式化

      0   或   100   (*)     默认值   mon   dd   yyyy   hh:miAM(或   PM)       1   101   美国   mm/dd/yyyy      ...

  6. [转]sql server 数据库日期格式化函数

    转至:http://www.cnblogs.com/hantianwei/archive/2009/12/03/1616148.html 0   或   100   (*)     默认值   mon ...

  7. [置顶] fmt日期格式化

    jstl中的日期格式化 <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> & ...

  8. 日期格式化标签<fmt:formatDate>&<fmt:setTimeZone>时区标签的使用demo

    日期格式化标签<fmt:formatDate>&<fmt:setTimeZone>时区标签的使用demo <%@ page contentType="t ...

  9. Java日期格式化方法

    首先获取当前系统时间的方法有两种:第一种可以用currentTimeMillis()方法获取,它其实产生的是一个当前的毫秒数,这个毫秒是自1970年1月1日0时起至现在的毫秒数,类型是long 型,可 ...

随机推荐

  1. 云原生数据库mysql对共享存储分布式文件系统的接口需求分析

    1. 引言 云原生数据库跟分布式mpp数据库是有差异的,虽然两者都是计算与存储分离,但是在资源的占用上有所不同.云原生数据库是shard everything架构,其依赖的存储资源.内存资源.事务资源 ...

  2. springboot中使用定时器

    springboot使用注解注册定时器 @Configuration @EnableScheduling public class WeatherDataTask implements Schedul ...

  3. C#LeetCode刷题之#217-存在重复元素(Contains Duplicate)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3772 访问. 给定一个整数数组,判断是否存在重复元素. 如果任何 ...

  4. C# NPOI计算Execl里面的公式

    我这里分两种情况处理 1.Execl中表格中存在公式,我们通过公式获取数据 我们通过Npoi,获取列的属性: private static object GetValueType(ICell cell ...

  5. 微信小程序扫码解析小程序码

    通过微信扫小程序码,跳转到应用小程序内, 如何解析小程序码的参数呢? 一般小程序码会跳转到设置的页面,如首页, 可以直接跳转到小程序首页,然后解析小程序携带的参数,再打开某个页面. (小程序码的路径要 ...

  6. Hydra's plan

    省选前的计划,实时更新(不知道能不能把挖的坑填完呢qwq) 链接

  7. Provisional headers are shown 问题的一种情况

    Provisional headers are shown 出现在请求头的报错里面,意思为 显示临时的头部,真实的意思是,请求没有收到服务器返回.如果出现类似情况, 可以在服务端找一找,是否没有给该请 ...

  8. guice的能力简述

    guice这个google出的bean容器框架,ES有用到他. 能干什么 是一个bean容器 能AOP 能力细分与使用方式 以module创建injector.可以看成是一个容器.Module需要自定 ...

  9. eric4 中pyqt 字符串 输入 获取

    在eric4中使用pyqt需要注意: 输入 中文 时,前面加 u ,例如: from PyQt4.QtGui import * from PyQt4.QtCore import * QMessageB ...

  10. idea github 上传项目

    1.创建本地仓库,VCS-->Import into Version Control-->Create Git Repository... 在弹框中选中项目所在的位置,点击OK,此时项目文 ...