1.格式化貨幣
世界上許多國家都有不同的貨幣格式和數字格式慣例。針對特定的本地化環境正確地格式化和顯示貨幣是本地化的一個重要部分。
<%@ page pageEncoding="UTF-8" %> <html> <title>Currency Formatting</title> <h3>English, Great Britain</h3> <h3>English, USA</h3> <h3>French, France</h3> <h3>Japanese, Japan</h3> <h3>Korean, Korea</h3> <h3>Spanish, Spain</h3> <h3>Arabic, Egypt</h3> <h3>Using Local Numeric Formatting for Different Currency</h3> </body> 2.格式化日期 類似于數字和貨幣格式化,本地化環境還會影響生成日期和時間的方式。 <%@ page pageEncoding="UTF-8" %> <html> <h3>English, Great Britain</h3> <h3>English, USA</h3> <h3>French, France</h3> <h3>Japanese, Japan</h3> <h3>Korean, Korea</h3> <h3>Spanish, Spain</h3> </fmt:timeZone> <fmt:formatDate>動作的屬性 type: 可以是time,date或both??刂剖欠裰簧蓵r間,只生成日期,或者時間日期都生成。 dateStyle: 可以是short, medium, long 或 full(default)??刂拼蛴∪掌谑褂玫木唧w格式。 timeStyle: 可以是short, medium, long 或 full(default)??刂拼蛴r間使用的具體格式。 value: 這是一個java.util.Date 類型的值,用于生成日期和時間。
<%@ taglib java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="
<head>
</head>
<body>
<h1>Currency Formatting and locales</h1>
<fmt:setLocale value="en_GB" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<fmt:setLocale value="en_US" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<fmt:setLocale value="fr_FR" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<fmt:setLocale value="ja_JP" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<fmt:setLocale value="ko_KR" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<fmt:setLocale value="es_ES" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<fmt:setLocale value="ar_EG" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<h4>English, Great Britan</h4>
<fmt:setLocale value="en_GB" />
<fmt:formatNumber type="currency" value="80000" /><br/>
<fmt:formatNumber type="currency" value="80000" currencyCode="EUR"/><br/>
</html>
<%@ taglib prefix="c" uri="<%@ taglib prefix="fmt" uri="
<head>
<title>Date Formatting</title>
</head>
<body>
<h1>Date Formatting and locale</h1>
<fmt:timeZone value="EST">
<jsp:useBean id="currentTime" class="java.util.Date"/>
<fmt:setLocale value="en_GB" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>
<fmt:setLocale value="en_US" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>
<fmt:setLocale value="fr_FR" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>
<fmt:setLocale value="ja_JP" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>
<fmt:setLocale value="ko_KR" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>
<fmt:setLocale value="es_ES" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>
<h3>Arabic, Egypt</h3>
<fmt:setLocale value="ar_EG" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>
</body>
</html>
新聞熱點
疑難解答