[SoapUI] 去除科学计数法,格式化小数点位数

def formatDecimalPrecision(def dataValue, int decimalPrecision){   
  def regEx_Numeric = '-?[1-9]\d*$|-?([1-9]\d*\.\d*|0\.\d*|0?\.0+|0)$' NumberFormat format
= NumberFormat.getNumberInstance() format.setMaximumFractionDigits(decimalPrecision) dataValue = dataValue.toString() if(dataValue.isBigDecimal()){ dataValue = new BigDecimal(dataValue).toPlainString() } if(dataValue.matches(regEx_Numeric)){ //Switch String to double firstly dataValue = Double.parseDouble(dataValue) dataValue = format.format(dataValue) dataValue = format.parse(dataValue).toString() } return dataValue }
原文地址:https://www.cnblogs.com/wynlfd/p/6687807.html