JSTL fmt: formatNumber format the date, number, and currency of the data, and jstlformatnumber
JSTL fmt: formatNumber date, number, and currency formatting
Use the <fmt> label
<% @ Taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>
Its uri can be in the fmt. tld File
1. Date formatting
<Fmt: formatDate value = "$ {XXX. date}" pattern = "yyyy-MM-dd HH: mm: ss"/> |
Value: the date to be formatted.
Pattern: Format of the date format
2. digit formatting
<Fmt: formatNumber value = "12" type = "currency" pattern = "$. 00"/> -- $12.00
<Fmt: formatNumber value = "12" type = "currency" pattern = "$. 0 #"/> -- $12.0
<Fmt: formatNumber value = "1234567890" type = "currency"/> -- $1,234,567,890.00 (the currency symbol is related to the local setting of the current web Server)
<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 can be currency, number, and percent) |
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. |