[Logo] JForum - Powering Communities
  [Search] 搜尋   [Recent Topics] 最新主題   [Hottest Topics] 熱門主題   [Top Downloads] 熱門下載   [Groups] 回首頁 
[Register] 會員註冊 /  [Login] 登入 


JForum 2.8.3 is out with various fixes and improvements. Read all about it here

Code test RSS feed
討論區首頁 » Test Me
發表人 內容
avec


註冊時間: 2014/2/22
文章: 9
離線

public class Format {

public static String numberFormat(int value) {
NumberFormat myFormatter = NumberFormat.getInstance();
return myFormatter.format(value);
}

public static String decimalFormat(String pattern, int value) {
DecimalFormat myFormatter = new DecimalFormat(pattern);
return myFormatter.format(value);
}

public static void main(String[] args) {
System.out.println(Format.readableFileSize(1000000));
}


public static String readableFileSize(long size) {
if (size <= 0) return "0";
final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
int digitGroups = (int) (Math.log10(size) / Math.log10(1000));
return new DecimalFormat("#,##0.#").format(size / Math.pow(1000, digitGroups)) + " " + units[digitGroups];

}
}
avec


註冊時間: 2014/2/22
文章: 9
離線

var speedCheck = (function (start) {
var end = new Date().getTime();
var time = (end - start);
alert("Time(millisec) : " + time);
});
 
討論區首頁 » Test Me
前往:   
行動版
Powered by JForum 2.8.3 © 2023 JForum Team • Maintained by Andowson Chang and Ulf Dittmer