package com.softeem.excel; import java.math.BigDecimal; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.regex.Pattern; public class TypeTools {//工具类 static SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");//日期转换格式 // private static DateFormat format; public static int getInt(String s){//字符串转int if(Pattern.matches("^\\d*$",s)){ return Integer.parseInt(s); } return 0; } public static double getDouble(String s){//字符转转double if(Pattern.matches("^\\d+\\.??\\d+$", s)){ return Double.parseDouble(s); } return 0.0; } //"" != null public static Date getDate(String s)//字符串转Date { Date date = null; try { if(s != null && !"".equals(s)){ date = sdf.parse(s); } } catch (ParseException e) { e.printStackTrace(); } return date; } public static BigDecimal getBigDecimal(String s)//字符串转BigDecimal { if(Pattern.matches("^\\d+\\.??\\d+$", s)){ return new BigDecimal(s); } return new BigDecimal("0.0"); } public static String getSring(Date date){//日期转字符串 if(date != null){ return sdf.format(date); } return null; } }
利用JXL实现对于excel-2000/2003版本的文件进行读写操作
最新推荐文章于 2018-01-20 09:58:36 发布