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

2016-02-19 20:19 6 1 收藏

下面是个JSP 国际化-格式化货币和日期教程,撑握了其技术要点,学起来就简单多了。赶紧跟着图老师小编一起来看看吧!

【 tulaoshi.com - Web开发 】

  1.格式化货币

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

  %@ page 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" %

  html
  head

  titleCurrency Formatting/title
  /head
  body
  h1Currency Formatting and locales/h1

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

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

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

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

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

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

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

  h3Using Local Numeric Formatting for Different Currency/h3
  h4English, 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="http://java.sun.com/jsp/jstl/core" %
  %@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %

  html
  head
  titleDate Formatting/title
  /head
  body
  h1Date Formatting and locale/h1
  fmt:timeZone value="EST"
  jsp:useBean id="currentTime" class="java.util.Date"/

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

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

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

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

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

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

  h3Spanish, Spain/h3
  fmt:setLocale value="es_ES" /
  fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /br/

  
  h3Arabic, Egypt/h3
  fmt:setLocale value="ar_EG" /
  fmt:formatDate type="both" dateStyle="full" timeStyle="full" value="${currentTime}" /br/

  /fmt:timeZone
  /body
  /html

  fmt:formatDate动作的属性

  type: 可以是time,date或both。控制是否只生成时间,只生成日期,或者时间日期都生成。

  dateStyle: 可以是short, medium, long 或 full(default)。控制打印日期使用的具体格式。

  timeStyle: 可以是short, medium, long 或 full(default)。控制打印时间使用的具体格式。

  value: 这是一个java.util.Date 类型的值,用于生成日期和时间。

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

来源:https://www.tulaoshi.com/n/20160219/1623334.html

延伸阅读
标签: ASP
  如果有一个数字498.8573945,如何把它格式化成两位小数据呢?用过ASP的都知道,在VbScript里我们可以调用FormatNumber,即用FormatNumber(498.8573945,2)就可以输出:498.86。 由于JavaScript里没有这个函数,那么我们该如何实现呢?下面我就给出这个函数,大家可以把:<SCRIPT LANGUAGE=javascript src="http://img.jcwcn.com/...
一:大家可以去百度一下搜索一款U盘杀毒专家。 二:点击下载,然后安装U盘查杀软件。 三:将U盘插入电脑,打开U盘杀毒专家,选择需要扫描对象,一共有内存、本地硬盘、移动存储设备三个选项,推荐全选,然后点击开始扫描。 ...
标签: Android
安卓手机怎么格式化   虽然Android手机品牌众多,但基本操作大同小异,所以这里便以三星手机为例进行介绍。 1.在待机页面下,点击。 2.点击(或)。 3.向上滑动屏幕,点击。 4.点击(即格式化)。 5.点击。 6.点击。 完成上述操作后,待图老师手机自动重启后,手机就成功恢复出厂设...
标签: Web开发
jQuery国际化插件可以让你在JavaScript代码中轻松地处理不同文化之间的数字、货币和日期格式。例如,你可以使用这个插件正确地显示一个国家的货币符号 上个月,我写了一篇关于微软如何在向 jQuery 贡献代码的文章,也谈到了在第一批贡献的代码中的一些功能:jQuery模板和数据链接支持. 今天,我们发布了一个新的jQuery国际化插件的原型,你...
一、国际化 准备资源文件,资源文件的命名格式如下: baseName_language_country.properties baseName_language.properties baseName.properties 其中baseName是资源文件的基本名,我们可以自定义,但language和country必须是java支持的语言和国家。如: 中国大陆: baseName_zh_CN.properties 美国: baseName_en_US.properties 现在为应...

经验教程

152

收藏

12
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部