Jsp-jstl-format-parsedate-tag

提供:Dev Guides
移動先:案内検索

JSTL-コア<fmt:parseDate>タグ

*<fmt:parseDate>* タグは、日付の解析に使用されます。

属性

*<fmt:parseDate>* タグには次の属性があります-
Attribute Description Required Default
Value Date value to read (parse) No Body
type DATE, TIME, or BOTH No date
dateStyle FULL, LONG, MEDIUM, SHORT, or DEFAULT No Default
timeStyle FULL, LONG, MEDIUM, SHORT, or DEFAULT No Default
parseLocale Locale to use when parsing the date No Default locale
pattern Custom parsing pattern No None
timeZone Time zone of the parsed date No Default time zone
var Name of the variable to store the parsed date No Print to page
scope Scope of the variable to store the formatted date No page
*<fmt:formatDate>* タグのパターン属性と同様に機能するパターン属性が提供されます。 ただし、構文解析の場合、パターン属性はパーサーにどの形式を期待するかを伝えます。

<%@ 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 Tag</title>
   </head>

   <body>
      <h3>Date Parsing:</h3>

      <c:set var = "now" value = "20-10-2010"/>
      <fmt:parseDate value = "${now}" var = "parsedEmpDate" pattern = "dd-MM-yyyy"/>
      <p>Parsed Date: <c:out value = "${parsedEmpDate}"/></p>

   </body>
</html>

上記のコードは、次の結果を生成します-

Date Parsing:
Parsed Date: Wed Oct 20 00:00:00 GST 2010