Date Representation
<FMT: formatdate
Value = "$ {date1 }"
Pattern = "yyyy-mm-dd hh: mm: SS" type = "date" datestyle = "long"/>
Percent, expressed as a thousand points
<FMT: formatnumber
Value = "$ {doublevalue}" type = "Number" pattern = "0.00 ‰"/> 0.01 ‰
<FMT: formatnumber
Value = "$ {doublevalue}" type = "Number" pattern = "0.00%"/>
0.20%
Other numbers
FMT: formatnumber value = "123456.7891" pattern = "#, #00.0 #"/> --
123,456.79
<FMT: formatnumber value = "123456.7" pattern = "#, #00.0 #"/> --
123,456.7
<FMT: formatnumber value = "123456.7" pattern = "#, #00.00 #"/> --
123,456.70
<FMT: formatnumber value = "12" type = "percent"/> -- 1,200% type
It can be currency, number, and percent.
Currency Representation
= 1
<FMT: setlocale
Value = "ch_ch"/>
<FMT: formatnumber value = "$ {data}" type = "currency"/>
= 2
<FMT: formatnumber value = "$ {doublevalue}" type = "Number"
Pattern = "¥0.00"/>
Reference
========================================================== ==============================================
Java formatted output:
Decimalformat df = new decimalformat ("format ");
String FMt = DF. Format (double );
Symbolic Meaning
0: one digit
# One digit, leading zero and ending zero are not displayed
. Decimal place
, Group separator location
-Negative number prefix
% Multiply by 100 and display the percentage sign
Other symbols include the specified symbols in the output string.
========================================================== ========================================================== =
And Shen's personal homepage "src =" http://hiphotos.baidu.com/a363359983/pic/item/3a7e4d501e002f5d367abea3.jpg "alt =" numbers of jstl, date formatting --- FMT: formatnumber/, FMT: formatdate/-and Shen-
And Shen's personal homepage ">
<% @ Page Language = "Java" contenttype = "text/html;
Charset = gb18030 "%>
<% @ Taglib uri = "http://java.sun.com/jsp/jstl/fmt
"
Prefix = "FMT" %>
<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core
"Prefix =" C"
%>
<HTML>
<Head>
<Title> my JSP 'fmt. jsp 'starting page </title>
</Head>
<Body>
<C: Set Var = "salary" value = "3540.2301"/>
<C: Set Var = "Total" value = "56225.2301"/>
<FMT: setlocale value = "en_us"/>
Currency: <FMT: formatnumber value = "$ {salary}" type = "currency"
Currencycode = "USD"/> <br>
Percent: <FMT: formatnumber value = "$ {salary/total }"
Type = "percent" maxfractiondigits = "4"/> <br>
<HR>
<JSP: usebean id = "now"
Class = "Java. util. Date"> </jsp: usebean>
<FMT: setlocale value = "zh_cn"/>
Full --> <FMT: formatdate value = "$ {now}" type = "both"
Datestyle = "full" timestyle = "full"/> <br>
Long --> <FMT: formatdate value = "$ {now}" type = "both"
Datestyle = "long" timestyle = "long"/> <br>
Medium --> <FMT: formatdate value = "$ {now}" type = "both"
Datestyle = "medium" timestyle = "medium"/> <br>
Default --> <FMT: formatdate value = "$ {now}" type = "both"
Datestyle = "default" timestyle = "default"/> <br>
Short --> <FMT: formatdate value = "$ {now}" type = "both"
Datestyle = "short" timestyle = "short"/> <br>
</Body>
</Html>
========================================================== ========================================================== =
JSP internationalization-format currency and date
1. format the currency
Many countries in the world have different currency formats and digital format conventions. Correct formatting and displaying currencies for specific localization environments 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
"
%>
<HTML>
<Head>
<Title> currency formatting </title>
</Head>
<Body>
<H1> currency formatting and locales
<H3> English, Great Britain <FMT: setlocale value = "en_GB"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
<H3> English, USA <FMT: setlocale value = "en_us"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
<H3> French, France <FMT: setlocale value = "fr_fr"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
<H3> Japan, Japan <FMT: setlocale value = "ja_jp"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
<H3> Korean, Korea <FMT: setlocale value = "ko_kr"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
<H3> Spanish, Spain <FMT: setlocale value = "es_es"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
<H3> Arabic, Egypt <FMT: setlocale value = "ar_eg"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
<H3> using local numeric formatting for different
Currency <H4> English, Great Britan </H4>
<FMT: setlocale value = "en_GB"/>
<FMT: formatnumber type = "currency" value = "80000"/> <br/>
& Lt; FMT: formatnumber type = "currency" value = "80000"
Currencycode = "EUR"/> <br/>
</Body>
</Html>
2. format the date
Similar to digital and currency formatting, the localization environment also affects the date and time of generation.
<% @ 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>
<Title> date formatting </title>
</Head>
<Body>
<H1> date formatting and locale <FMT: timezone value = "est">
<JSP: usebean id = "currenttime" class = "Java. util. Date"/>
<H3> English, Great Britain <FMT: setlocale value = "en_GB"/>
<FMT: formatdate type = "both" datestyle = "full" timestyle = "full"
Value = "$ {currenttime}"/> <br/>
<H3> English, USA <FMT: setlocale value = "en_us"/>
<FMT: formatdate type = "both" datestyle = "full" timestyle = "full"
Value = "$ {currenttime}"/> <br/>
<H3> French, France <FMT: setlocale value = "fr_fr"/>
<FMT: formatdate type = "both" datestyle = "full" timestyle = "full"
Value = "$ {currenttime}"/> <br/>
<H3> Japan, Japan <FMT: setlocale value = "ja_jp"/>
<FMT: formatdate type = "both" datestyle = "full" timestyle = "full"
Value = "$ {currenttime}"/> <br/>
<H3> Korean, Korea <FMT: setlocale value = "ko_kr"/>
<FMT: formatdate type = "both" datestyle = "full" timestyle = "full"
Value = "$ {currenttime}"/> <br/>
<H3> Spanish, Spain <FMT: setlocale value = "es_es"/>
<FMT: formatdate type = "both" datestyle = "full" timestyle = "full"
Value = "$ {currenttime}"/> <br/>
<H3> Arabic, Egypt <FMT: setlocale value = "ar_eg"/>
<FMT: formatdate type = "both" datestyle = "full" timestyle = "full"
Value = "$ {currenttime}"/> <br/>
</FMT: timezone>
</Body>
</Html>
<FMT: formatdate> Action attributes
Type: It can be time, date, or both. Determines whether to generate only the time, only the date, or the time and date are generated.
Datestyle: It can be short, medium, long or full (default ). Controls the specific format of the print date.
Timestyle: It can be short, medium, long or full (default ). Control the specific format of the printing time.
Value: A value of the Java. util. date type, used to generate the date and time.