java中Double類數字太大時頁面正常顯示而不要用科學計數法


 

    /**
     * 當浮點型數據位數超過10位之后,數據變成科學計數法顯示。用此方法可以使其正常顯示。
     * @param value
     * @return Sting
     */
    public static String formatFloatNumber(double value) {
        if(value != 0.00){
            java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
            return df.format(value);
        }else{
            return "0.00";
        }

    }
    public static String formatFloatNumber(Double value) {
        if(value != null){
            if(value.doubleValue() != 0.00){
                java.text.DecimalFormat df = new java.text.DecimalFormat("########.00");
                return df.format(value.doubleValue());
            }else{
                return "0.00";
            }
        }
        return "";
    }

 

DecimalFormat   format   =   (DecimalFormat)   NumberFormat.getPercentInstance(); 
format.applyPattern( "#####0 "); 
String   temp   =   format.format(Double.MAX_VALUE); 
System.out.println(temp);

 

double   a;   //   test 
DecimalFormat   df   =     new   DecimalFormat( "###############0.00 ");//   16位整數位,兩小數位 
String   temp     =   df.format(a); 
System.out.println(temp);

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM