Balise <fmt:parseDate>
Bibliothèque de balises standard JSP
La balise <fmt:parseDate> est utilisée pour analyser les dates.
Syntaxe
<fmt:parseDate value="<string>" type="<string>" dateStyle="<string>" timeStyle="<string>" pattern="<string>" timeZone="<string>" parseLocale="<string>" var="<string>" scope="<string>"/>
Attributes
La balise <fmt:parseDate> possède les attributs suivants :
| Attribut | Description | Requis | Valeur par défaut |
|---|---|---|---|
| value | La date à afficher | Oui | Aucune |
| type | DATE, TIME ou BOTH | non | date |
| dateStyle | FULL, LONG, MEDIUM, SHORT ou DEFAULT | non | default |
| timeStyle | FULL, LONG, MEDIUM, SHORT ou DEFAULT | non | default |
| pattern | Modèle de format personnalisé | non | Aucune |
| timeZone | Le fuseau horaire pour afficher la date | non | Fuseau horaire par défaut |
| var | Le nom de variable pour stocker la date formatée | non | Affiché sur la page |
| scope | La portée pour stocker la variable de date formatée | non | Page |
L'attribut définit le format d'heure dont nous avons besoin pour la sortie.
Démonstration d'exemple
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>JSTL fmt:parseDate 标签</title>
</head>
<body>
<h3>日期解析:</h3>
<c:set var="now" value="20-10-2015" />
<fmt:parseDate value="${now}" var="parsedEmpDate"
pattern="dd-MM-yyyy" />
<p>解析后的日期为: <c:out value="${parsedEmpDate}" /></p>
</body>
</html>
Le résultat de l'exemple ci-dessus :
日期解析: 解析后的日期为: Tue Oct 20 00:00:00 CST 2015
Autres extensions