[JSTL] JSTL fmt 예제 - formatNumber, formatDate

2008. 8. 25. 09:56컴퓨터 프로그램/JSTL

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ 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 예제 - formatNumber, formatDate</title>
</head>
<body>
 number  : <fmt:formatNumber value="12345.678" type="number"/><br>
 currency: <fmt:formatNumber value="12345.678" type="currency" currencySymbol="₩"/><br>
 percent : <fmt:formatNumber value="12345.678" type="percent"/><br>
 pattern=".0" :<fmt:formatNumber value="12345.678" pattern=".0"/> <p>

 <c:set var="now" value="<%=new java.util.Date()%>"/>
 <c:out value="${now}"/><br>
 date: <fmt:formatDate value="${now}" type="date"/> <br>
 time: <fmt:formatDate value="${now}" type="time"/> <br>
 both: <fmt:formatDate value="${now}" type="both"/>
</body>
</html>