JSP 国际化-格式化货币和日期

时间:2010-01-22 14:08:50  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:a.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core" %><%@ taglib prefix="fmt" uri="java.sun.com/jsp/jstl/fmt">http://java.sun.com/jsp/jstl/fmt" %><html><head><title>Currency Formatting</title></head><body><h1>Currency Formatting and locales</h1><h3>...
  正文:

1.格式化货币

世界上许多国家都有不同的货币格式和数字格式惯例。针对特定的本地化环境正确地格式化和显示货币是本地化的一个重要部分。

<%@ page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="java.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="java.sun.com/jsp/jstl/fmt">http://java.sun.com/jsp/jstl/fmt" %>

<html>
<head>

<title>Currency Formatting</title>
</head>
<body>
<h1>Currency Formatting and locales</h1>

<h3>English, Great Britain</h3>
<fmt:setLocale value="en_GB" />
<fmt:formatNumber type="currency" value="80000" /><br/>

<h3>English, USA</h3>
<fmt:setLocale value="en_US" />
<fmt:formatNumber type="currency" value="80000" /><br/>

<h3>French, France</h3>
<fmt:setLocale value="fr_FR" />
<fmt:formatNumber type="currency" value="80000" /><br/>

<h3>Japanese, Japan</h3>
<fmt:setLocale value="ja_JP" />
<fmt:formatNumber type="currency" value="80000" /><br/>

<h3>Korean, Korea</h3>
<fmt:setLocale value="ko_KR" />
<fmt:formatNumber type="currency" value="80000" /><br/>

<h3>Spanish, Spain</h3>
<fmt:setLocale value="es_ES" />
<fmt:formatNumber type="currency" value="80000" /><br/>

<h3>Arabic, Egypt</h3>
<fmt:setLocale value="ar_EG" />
<fmt:formatNumber type="currency" value="80000" /><br/>

<h3>Using Local Numeric Formatting for Different Currency</h3>
<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/>

</body>
</html>

2.格式化日期

类似于数字和货币格式化,本地化环境还会影响生成日期和时间的方式。

<%@ page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="java.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="java.sun.com/jsp/jstl/fmt">http://java.sun.com/jsp/jstl/fmt" %>

<html>
<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"/>

<h3>English, Great Britain</h3>
<fmt:setLocale value="en_GB" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>

<h3>English, USA</h3>
<fmt:setLocale value="en_US" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>

<h3>French, France</h3>
<fmt:setLocale value="fr_FR" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>

<h3>Japanese, Japan</h3>
<fmt:setLocale value="ja_JP" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>

<h3>Korean, Korea</h3>
<fmt:setLocale value="ko_KR" />
<fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /><br/>

<h3>Spanish, Spain</h3>
<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" />
JSP 国际化-格式化货币和日期》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/JSP/12227.html


关键字:

关于《JSP 国际化-格式化货币和日期》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td