<%
Locale loc = Locale.getDefault();
NumberFormat nf = NumberFormat.getCurrencyInstance(loc);
%>
<%= nf.format(1000000)); %>
Output: $1,000,000.00
<% DecimalFormat formatter = new DecimalFormat("###,###,###"); %> <%= formatter.format(1000000)+" VNĐ"); %> Output: 1,000,000 VNĐ
==Java Core==
DecimalFormat formatter = new DecimalFormat("###,###,###"); System.out.println(formatter.format(1000000)+" VNĐ"); Output: 1,000,000 VNĐ
DecimalFormat formatter = new DecimalFormat("###,###,###.00");
System.out.println(formatter.format(1000000)+" VNĐ");
Output: 1,000,000.00 VNĐ
DecimalFormat formatter = new DecimalFormat("###,###,###.##");
System.out.println(formatter.format(1000000)+" VNĐ");
Output: 1,000,000 VNĐ
Locale loc = Locale.getDefault();
NumberFormat nf = NumberFormat.getCurrencyInstance(loc);
System.out.println(nf.format(1000000)+" VNĐ");
Output: $1,000,000.00
Locale lc = new Locale("nv","VN"); //Định dạng locale việt nam
//Locale lc = new Locale("fr","FR");
//Định dạng số NUMBER
NumberFormat nf = NumberFormat.getInstance(lc);
nf.format(123456);
//Định dạng phần trăm %
NumberFormat pf = NumberFormat.getPercentInstance(lc);
pf.format(20.99);
//Định dạng thời gian TIME
DateFormat df = NumberFormat.getDateInstance(DateFormat.DÈFAULT.lc);
df.format(new Date());
//Định dạng tiền tệ $
NumberFormat nf = NumberFormat.getCurrencyInstance(lc);
nf.format(123456);
0 nhận xét:
Post a Comment