2015년 1월 30일 금요일

fmt

<%@ page language="java" contentType="text/html; charset=EUC-KR"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:useBean id="date" class="java.util.Date"/>
<html>
<head>
<title>JSTL fmt 라이브러리 사용 예제</title>
</head>
<body>
<%-- <fmt:setLocale value="ko_KR" scope="session"/>  언어를 한글로 지정시 --%>
<fmt:setLocale value="en_US" scope="session"/>
<fmt:bundle basename="test">
 <fmt:message key="name"/><br>
 <fmt:message key="say"/><br>
 <fmt:message key="say2">
  <fmt:param value="고길동"/>
 </fmt:message>
</fmt:bundle>
<p>
<fmt:formatNumber value="50000" type="currency"/><br>
<fmt:formatNumber value="0.15" type="percent"/><br>
<fmt:formatNumber value="500567300" pattern="###,###,###"/><p>
<fmt:formatDate value="${date}" type="date"/><br>
<fmt:formatDate value="${date}" type="time"/><br>
<fmt:formatDate value="${date}" type="both"/><p>
<fmt:formatDate value="${date}" type="both"
timeStyle="short" dateStyle="short"/><br>
<fmt:formatDate value="${date}" type="both"
timeStyle="long" dateStyle="long"/><br>
</body>
</html>

숫자1 : <fmt:formatNumber value="123456789" type="number"/><br>
숫자2 : <fmt:formatNumber value="1000" type="currency" currencySymbol="₩"/><br>
숫자3 : <fmt:formatNumber value="0.3" type="percent"/><br>
숫자4 : <fmt:formatNumber value="12345.678" pattern=".00"/><br>


<결과값>
숫자1 : 123,456,789  <- 기본 천단위 끊어서 표현
숫자2 : ₩ 1,000.00  <- 원표시 붙이고 (,)붙이고 소수점 2개 까지 표현
숫자3 : 30%   <- %로 표현
숫자4 : 12345.68  <- 설정 소수점에서 반올림으로 표

댓글 없음:

댓글 쓰기