Commit c223d4e4ec4e908d12776f22f48b99ff4525aed1
1 parent
84ecc89f
增加数据格式检验,避免设备返回错误格式造成抛错误
Showing
1 changed file
with
25 additions
and
0 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java
0 → 100644
| 1 | +package com.genersoft.iot.vmp.gb28181.utils; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 数值格式判断和处理 | ||
| 5 | + * @author lawrencehj | ||
| 6 | + * @date 2021年1月27日 | ||
| 7 | + */ | ||
| 8 | +public class NumericUtil { | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * 判断是否Double格式 | ||
| 12 | + * @param str | ||
| 13 | + * @return true/false | ||
| 14 | + */ | ||
| 15 | + public static boolean isDouble(String str) { | ||
| 16 | + try { | ||
| 17 | + Double num2 = Double.valueOf(str); | ||
| 18 | + System.out.println("Is Number!" + num2); | ||
| 19 | + return true; | ||
| 20 | + } catch (Exception e) { | ||
| 21 | + System.out.println("Is not Number!"); | ||
| 22 | + return false; | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | +} |