Here you can find the source of numberFormat(Number number, String... pattern)
public static String numberFormat(Number number, String... pattern)
//package com.java2s; //License from project: Apache License import java.io.*; import java.text.DecimalFormat; import java.text.Format; import java.util.List; import java.util.Map; import java.util.Set; public class Main { private static Format FORMAT = new DecimalFormat("#.##"); public static String numberFormat(Number number, String... pattern) { return isNull((Object[]) pattern) ? FORMAT.format(number) : FORMAT.format(pattern[0]); }//from w w w . ja v a 2 s. c o m public static boolean isNull(Object o) { return null == o; } public static boolean isNull(List<?> list) { return null == list || list.size() == 0; } public static boolean isNull(Set<?> set) { return null == set || set.size() == 0; } public static boolean isNull(Map<?, ?> map) { return null == map || map.size() == 0; } public static boolean isNull(Long lg) { return null == lg || lg.longValue() == 0L; } public static boolean isNull(Integer it) { return null == it || it.intValue() == 0; } public static boolean isNull(File file) { return null == file || !file.exists(); } public static boolean isNull(Object[] strs) { return null == strs || strs.length == 0; } }