Home > Java > javaTutorial > Common methods for data conversion in java POI parsing Excel

Common methods for data conversion in java POI parsing Excel

高洛峰
Release: 2017-01-24 13:45:19
Original
1692 people have browsed it

As shown below:

public static String reThreeStr(String ss){
 
      boolean result= ss.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$"); 
      if(result&&ss!=null&&!"".equals(ss)){
        Double sss=Double.valueOf(ss);
      String numStr=new java.text.DecimalFormat("0.000").format(sss);
      Double lsDou=Double.valueOf(numStr);
      ss=String.valueOf(lsDou);
      }
    return ss;
  }
 
public static BigDecimal reThreeBig(BigDecimal ss){
  String numStr=new java.text.DecimalFormat("0.000").format(ss);
  BigDecimal newNum=new BigDecimal(numStr);
  return newNum;
}
  public static String delezero(String old){
     boolean result= old.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
     if(result&&old!=null&&!"".equals(old)){
       String newStr=old;
        if(old.contains(".0")){
          old=newStr.substring(0, old.length()-2);
        }
        return old;
     }else{
       return old;
     }
     
  }
Copy after login

The above common method of data conversion (recommended) for java POI parsing Excel is all the content shared by the editor , I hope it can give you a reference, and I also hope that everyone will support the PHP Chinese website.

For more articles related to the data conversion public method of java POI parsing Excel, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template