Tôi đã cố gắng thực hiện đơn vị tiền tệ thủ công. Đây là mã của tôiLàm cách nào để đặt tiền tùy chỉnh trong java?
DecimalFormat df = new DecimalFormat();
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setCurrencySymbol("$");
dfs.setGroupingSeparator('.');
dfs.setDecimalSeparator('.');
df.setDecimalFormatSymbols(dfs);
System.out.println(df.format(3333454));
đầu ra Chương trình được
3.333.454
Tại sao các biểu tượng tiền tệ tôi đặt đã không xuất hiện?
nhờ anh chàng, nó hoạt động. Nhưng làm thế nào để loại bỏ 2 chữ số thập phân phía sau? – greenthunder
Thêm 'df.setMaximumFractionDigits (0);' – mprivat
Đây có vẻ là một giải pháp tuyệt vời !!!!! –