JSTL Core fmt parseDate Tag

JSTL Core fmt parseDate Tag

JSTL Core fmt:parseDate Tag

Below is standard syntax to include in your JSP page:

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

JSP example:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <h2>fmt:parseDate example</h2>


    <h3>Formatted date</h3>

    <fmt:parseDate value="20-05-2014" var="current" pattern="dd-MM-yyyy" />
    <p>
        Parsed Date:
        <c:out value="${current}" />
    </p>

    <fmt:parseDate value="2014-05-20" var="current" pattern="yyyy-MM-dd" />
    <p>
        Parsed Date:
        <c:out value="${current}" />
    </p>

    <fmt:parseDate value="05-20-2014" var="current" pattern="MM-dd-yyyy" />
    <p>
        Parsed Date:
        <c:out value="${current}" />
    </p>



</body>
</html>

Output:

JSTL Core fmt parseDate Tag

 

download Download Project: jstl-1.2

Leave a Reply

Your email address will not be published. Required fields are marked *