一句话,BigDecimal转为字符串,匹配正则表达式,so easy;

不废话,代码:

import java.math.BigDecimal;
import java.util.regex.Pattern; public class test {
public static void main(String[] args) {
BigDecimal a = new BigDecimal(1000);
BigDecimal b = new BigDecimal(99.999);
String integerStr = a+"" ;
String doubleStr = b+"";
System.out.println(Pattern.matches("\\d+", integerStr));//判断是否可转换为Integer(short即long可以发散,就是改正则)
System.out.println(Pattern.matches("\\d+\\.+", integerStr));//判断是否可转换为Double
}
}

最新文章

  1. winform窗体控件(全)
  2. Android using Accelerometer
  3. 深入理解AOP
  4. YTU 3022: 完全二叉树(1)
  5. 在 Tomcat 中设置 JDBCRealm
  6. IB_DESIGNABLE的使用
  7. 利用反射动态构成sql语句
  8. 【Andord真】SlideMenu+ViewPagerIndictor双滑动边栏+滑动导航条
  9. USACO 3.4 Raucous Rockers
  10. apicloud教程1 (转载)
  11. 笔记:Spring Cloud Hystrix Command属性
  12. mongoVUE破解与配置、Mongodb数据库安装
  13. mysql远程访问1045的问题解决
  14. 什么是arp协议?
  15. HTML特殊符号(字符实体)大全
  16. codeforces 13EE. Holes(分块&动态树)
  17. bootstrapTable使用场景及方式
  18. AtCoder Beginner Contest 120 解题报告
  19. Vue.set全局操作
  20. MySQL篇,第二章:数据库知识2

热门文章

  1. C语言库函数大全及应用实例九
  2. 探讨css中repaint和reflow
  3. 完整的thinphp+phpexcel实现excel报表的输出(有图有效果)
  4. 验证(C#和正则表达式)
  5. 2.2 LINQ中使用from子句指定数据源
  6. vim的复制粘贴小结
  7. javascript 学习总结(六)RegExp对象
  8. PHP:Cannot modify header information - headers already sent by错误的解决方案
  9. 用css样式围剿等高列问题(转载)
  10. 值为NULL的对象指针