JSP internationalization-format currency and date

Source: Internet
Author: User
Tags date format
js| Currency | date

1. Format currency

Many countries in the world have different currency formats and digital format conventions. correctly formatting and displaying the currency for a specific localized environment is an important part of localization.

<%@ 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"%>
<title>currency formatting</title>
<body>
<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/>
<fmt:setlocale value= "en_GB"/>
<fmt:formatnumber type= "Currency" value= "80000"/><br/>
<fmt:formatnumber type= "Currency" value= "80000" currencycode= "EUR"/><br/>
</body>

2. Format Date

Similar to digital and currency formatting, the localization environment also affects how dates and times are generated.

<%@ 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"%>
<title>date formatting</title>
<body>
<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/>
<fmt:setlocale value= "Ar_eg"/>
<fmt:formatdate type= "Both" datestyle= "full" timestyle= "full" value= "${currenttime}"/><br/>
</fmt:timeZone>
</body>

Properties of <fmt:formatDate> Actions
Type: can be time,date or both. Controls whether only the time is generated, only the date is generated, or the time date is generated.
Datestyle: Can be short, medium, long or full (default). Controls the exact format used by the print date.
Timestyle: Can be short, medium, long or full (default). Controls the specific format used for printing time.
Value: This is a java.util.Date type value that is used to generate the date and time.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.