welcoming

前台输入手机号13777777777,如果是为Double类型接收,就会自动转为科学计数法

 

找了下,一般是Double转String,方法一般有两种:

 

1.利用String.format()

saleUnilateImport.setPhone(String.format("%.4f",row.getCell(1).getNumericCellValue()));//15145117218.0000保留4位小数

String.format("%.0f", row.getCell(0).getNumericCellValue())//15145117218,取整!

 

2.利用DecimalFormat类

DecimalFormat df = new DecimalFormat("#");//转换成整型


saleUnilateImport.setPhone(df.format(row.getCell(1).getNumericCellValue()));

 

3.利用DecimalFormat类

DecimalFormat df = new DecimalFormat("#,##0.00");//保留两位小数且不用科学计数法

saleUnilateImport.setPhone(df.format(row.getCell(1).getNumericCellValue()));

 

 

 

 

转自:http://free9277.blog.163.com/blog/static/11641721220111127111239951/

分类:

技术点:

相关文章:

  • 2021-12-25
  • 2021-08-27
  • 2022-12-23
  • 2021-04-03
  • 2022-12-23
  • 2021-10-23
猜你喜欢
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-12-02
  • 2021-12-05
  • 2022-12-23
相关资源
相似解决方案