java 获取传入值的区间

 1 /**
 2      * 获取值的区间
 3      *
 4      * @param num 值
 5      */
 6     public static Map<String, Integer> getNumSection(Integer num) {
 7         Map<String, Integer> map = new HashMap();
 8         int length = num.toString().length();
 9         if (length == 1) {   //判断是否为个数 1234567890
10             map.put("maxNum", 0);
11             map.put("minNum", 10);
12             return map;
13         }
14         String count = "";
15         for (int i = 1; i < length; i++) {
16             count += "0";
17         }
18         String shou = num.toString().substring(0, 1); //获取首位
19         int minNum = Integer.parseInt(shou + count);//最小
20         int maxNum = Integer.parseInt(String.valueOf(Integer.parseInt(shou) + 1) + count);//最大
21         map.put("maxNum", maxNum);
22         map.put("minNum", minNum);
23         return map;
24     }

 

posted @ 2020-07-20 11:56  阿_闯  阅读(1117)  评论(0编辑  收藏  举报