πŸ’»

JSPν”„λ‘œκ·Έλž˜λ° - [JSTL] fmt λ³Έλ¬Έ

KITRI/JSP

JSPν”„λ‘œκ·Έλž˜λ° - [JSTL] fmt

λ˜νš¨λ‹ˆ 2020. 6. 29. 14:33

formatting tags

 

μ„œμ‹νƒœκ·ΈλŠ” λ©”μ‹œμ§€ ν˜•μ‹, 번호 및 λ‚ μ§œ ν˜•μ‹ 등을 μ§€μ›ν•œλ‹€.

κ΅­μ œν™” 된 μ›Ή μ‚¬μ΄νŠΈμ—μ„œ ν…μŠ€νŠΈ, μ‹œκ°„, λ‚ μ§œ 및 숫자λ₯Ό ν‘œμ‹œν•˜κ³  ν˜•μ‹ν™”ν•˜λŠ”λ° μ‚¬μš©ν•œλ‹€.

 

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

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3>숫자λ₯Ό λ¬Έμžμ—΄ λ³€ν™˜</h3>
	number:
		<fmt:formatNumber value="12345.678" type="number"/>
	
	currency:
		<fmt:formatNumber value="12345.678" type="currency"/>
		<fmt:formatNumber value="12345.678" type="currency" currencySymbol="$"/>
	
	percent:
		<fmt:formatNumber value="12345.648" pattern=".0000"/> <%-- #, 0 --%>
		
	<h3>λ¬Έμžμ—΄μ„ 숫자 λ³€ν™˜</h3>
	<c:set var="str" value="${'1000'}"/>
	<fmt:parseNumber var="pNum" value="${str}"/>
	
	<fmt:parseNumber var="isu" value="55.7" integerOnly="true"/>
	${isu}
	
	<h3>λ‚ μ§œλ₯Ό λ¬Έμžμ—΄ λ³€ν™˜</h3>
	<jsp:useBean id="date" class="java.util.Date"/>
	<c:set var="today" value="${date}"/>
	
	λ‚ μ§œ: <fmt:formatDate value="${date}" type="date"/><br />
	μ‹œκ°„: <fmt:formatDate value="${date}" type="time"/><br />
	λ‚ μ§œμ‹œκ°„: <fmt:formatDate value="${date}" type="both"/><br />

	λ‚ μ§œμ‹œκ°„: <fmt:formatDate value="${date}" type="both" dateStyle="short" timeStyle="short"/><br />
	λ‚ μ§œμ‹œκ°„: <fmt:formatDate value="${date}" type="both" dateStyle="long" timeStyle="long"/><br />
	
	νŒ¨ν„΄: <fmt:formatDate value="${date}" pattern="yyyy-MM-dd HH:mm:ss"/><br />
	
	<h3>λ¬Έμžμ—΄μ„ λ‚ μ§œ λ³€ν™˜</h3>
	<c:set var="nowdate" value="2019-12-25 12:00:21"/>
	<fmt:parseDate value="${nowdate}" pattern="yyyy-MM-dd HH:mm:ss"/>
	<fmt:formatDate value="${now}" pattern="${date}"/>
</body>
</html>

 

 

λ°˜μ‘ν˜•
Comments