如何格式化数字.00到0.00?

时间:2016-02-15 06:38:11

标签: java format

NumberFormat nf = new DecimalFormat("##,###.00");  
String str = nf.format(0);  
System.out.println(str);  

如果num不为0,则结果正确。
但当num为0时,结果为.00,
如何使结果为0.00?

1 个答案:

答案 0 :(得分:1)

请改用此数字格式:

         Create table A(Id int,Name varchar(50))
         create table B(Id int,A_Id int,Title varchar(50))

        insert into A Values(1,'name1');
        insert into A Values(2,'name2');
        insert into A Values(3,'name3');
        insert into A Values(4,'name4');

        insert into B Values(10,1,'title1');
        insert into B Values(11,1,'title5');
        insert into B Values(12,2,'title2');
        insert into B Values(13,2,'title6');
        insert into B Values(14,3,'title3');