會員註冊 / 登入  |  電腦版  |  Jump to bottom of page

Test Me » Code test

發表人: avec
10 年 前

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
10 年 前

var speedCheck = (function (start) {
var end = new Date().getTime();
var time = (end - start);
alert("Time(millisec) : " + time);
});




會員註冊 / 登入  |  電腦版  |  Jump to top of page