숫자 천단위마다 콤마 찍어 구분
<fmt:formatNumber value="${vo.basket_goods_amount}" groupingUsed="true"/>
금액 표시
<fmt:formatNumber value="${vo.goods_price}" pattern="\#,###.##"/>
날짜 표시
<fmt:formatDate value="${vo.basket_date}" type="both" pattern="yyyy-MM-dd(E)"/>
<%@ 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"%>
<%@page import="java.util.*" %>
<c:set var="date" value="<%=new Date() %>"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
[오늘의 날짜]<fmt:formatDate value="${date}" type="date"/><br/> <%-- 정해진폼의 날짜 formatDate --%>
[오늘의 날짜]<fmt:formatDate value="${date}" type="both"/><br/>
[현재의 시간]<fmt:formatDate value="${date}" type="time"/><br/>
[오늘의 날짜:S]<fmt:formatDate value="${date}" type="both" dateStyle="short" timeStyle="short"/><br/>
[오늘의 날짜:M]<fmt:formatDate value="${date}" type="both" dateStyle="medium" timeStyle="medium"/><br/>
[오늘의 날짜:L]<fmt:formatDate value="${date}" type="both" dateStyle="long" timeStyle="long"/><br/>
[오늘의 날짜:F]<fmt:formatDate value="${date}" type="both" dateStyle="full" timeStyle="full"/><br/>
[오늘의 날짜]<fmt:formatDate value="${date}" type="date" pattern="yyyy-MM-dd"/><br/>
[오늘의 날짜]<fmt:formatDate value="${date}" type="time" pattern="(a)hh:mm:ss"/><br/>
</body>
</html>
======================================================================
<%@ 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"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
첫번째 수:<fmt:formatNumber value="1234500" groupingUsed="true"/><br/><%-- groupingUsed는 천단위마다 콤마를찍음(디폴트로 정해짐) --%>
두번째 수:<fmt:formatNumber value="3.14158" pattern="##.##"/><br/><%-- #은 자리표기 숫자가 없으면 공백으로--%>
세번째 수:<fmt:formatNumber value="10.5" pattern="#.00"/><br/><%-- 0은 자리표기 숫자가 없으면 0으로--%>
금액:<fmt:formatNumber value="${vo.goods_price}" pattern="\#,###.##"/>
금액:<fmt:formatNumber value="1000000" type="currency" currencySymbol="₩"/><br/>
금액:<fmt:formatNumber value="1000000" pattern="$#,###.00"/><br/>
퍼센트:<fmt:formatNumber value="0.99" type="percent"/><br/>
퍼센트:<fmt:formatNumber value="0.99" pattern="#,###.00%"/><br/>
</body>
</html>
[출처] - http://www.cyworld.com/java_ee/6102196
'Carpe Programming > jsp & spring & jstl' 카테고리의 다른 글
[jstl] jstl 글자수 자르기 (0) | 2011.08.19 |
---|---|
[jstl] jstl과 el로 목록 순번 표시하기 (0) | 2011.08.19 |
[jstl] 현재 날짜 구하기 (0) | 2011.08.16 |
jstl indexOf 적용 (0) | 2011.08.16 |
[vo] 넘어오는 value 확인 (0) | 2011.08.08 |