飞镖货币格式 [英] Currency format in dart
本文介绍了飞镖货币格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C#中我可以做到:
12341.4.ToString("##,#0.00")
结果为12,345.40
and the result is 12,345.40
飞镖的等效值是多少?
What's the equivalent in dart?
推荐答案
我也想找到解决方案,发现它现在已按照以下示例实现。
I wanted to find the solution also, and found that it is now implemented as per following example.
import 'package:intl/intl.dart';
final oCcy = new NumberFormat("#,##0.00", "en_US");
void main () {
print("Eg. 1: ${oCcy.format(123456789.75)}");
print("Eg. 2: ${oCcy.format(.7)}");
print("Eg. 3: ${oCcy.format(12345678975/100)}");
print("Eg. 4: ${oCcy.format(int.parse('12345678975')/100)}");
print("Eg. 5: ${oCcy.format(double.parse('123456789.75'))}");
/* Output :
Eg. 1: 123,456,789.75
Eg. 2: 0.70
Eg. 3: 123,456,789.75
Eg. 4: 123,456,789.75
Eg. 5: 123,456,789.75
pubspec.yaml :
name: testCcy002
version: 0.0.1
author: BOH
description: Test Currency Format from intl.
dev_dependencies:
intl: any
Run pub install to install "intl"
*/
}
这篇关于飞镖货币格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文