Skip to content

Commit

Permalink
commit V1.0:
Browse files Browse the repository at this point in the history
主要包括:基础类、excel解析生成、图片操作、敏感字
  • Loading branch information
chenssy89 committed Aug 13, 2015
1 parent 3a9b21d commit eda0c84
Show file tree
Hide file tree
Showing 20 changed files with 4,342 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="G:/myYunFile/个人积累/搜集资料/常用JAR包/POI/导入包/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="G:/myYunFile/个人积累/搜集资料/常用JAR包/POI/导入包/poi-3.8-20120326.jar"/>
<classpathentry kind="lib" path="G:/myYunFile/个人积累/搜集资料/常用JAR包/POI/导入包/poi-examples-3.8-20120326.jar"/>
<classpathentry kind="lib" path="G:/myYunFile/个人积累/搜集资料/常用JAR包/POI/导入包/poi-ooxml-3.8-20120326.jar"/>
<classpathentry kind="lib" path="G:/myYunFile/个人积累/搜集资料/常用JAR包/POI/导入包/poi-ooxml-schemas-3.8-20120326.jar"/>
<classpathentry kind="lib" path="G:/myYunFile/个人积累/搜集资料/常用JAR包/POI/导入包/poi-scratchpad-3.8-20120326.jar"/>
<classpathentry kind="lib" path="G:/myYunFile/个人积累/搜集资料/常用JAR包/POI/导入包/xmlbeans-2.3.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
122 changes: 122 additions & 0 deletions src/com/JUtils/base/BigDecimalUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.JUtils.base;

import java.math.BigDecimal;

/**
* 提供精确的加减乘除运算
* @Project:JUtils
* @file:BigDecimalUtils.java
* @Authro:chenming
* @data:2014年9月15日
*/
public class BigDecimalUtils {

/**
* 默认保留位:2
*/
private static int DEFAULT_SCALE = 2;

/**
* 默认四舍五入规则为:向上舍入
*/
private static int DEFAULT_ROUND = BigDecimal.ROUND_HALF_UP;

/**
*
* 加法运算
* @autor:chenming
* @data:2014年9月15日
*
* @param v1
* @param v2
* @return
*/
public static String add(String v1,String v2){
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.add(b2).toString();
}

/**
* 除法运算<br>
* 当发生除不尽的情况时,由scale参数指定精度,以后的数字四舍五入。
* @autor:chenming
* @data:2014年9月15日
*
* @param v1
* 除数
* @param v2
* 被除数
* @param scale
* 精确精度
* @return
*/
public static String div(String v1,String v2,int scale,int round){
if(scale<0){
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}

if(ValidateHelper.isEmpty(scale)){
scale = DEFAULT_SCALE;
}

if(ValidateHelper.isEmpty(round)){
round = DEFAULT_ROUND;
}

BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).toString();
}

/**
* 比较两个数<br>
* v1 > v2 return 1<br>
* v1 = v2 return 0<br>
* v1 < v2 return -1
* @autor:chenming
* @data:2014年9月15日
*
* @param v1
* 比较数
* @param v2
* 被比较数
* @return
*/
public static int compareTo(String v1,String v2){
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.compareTo(b2);
}

/**
* 返回较小数
* @autor:chenming
* @data:2014年9月15日
*
* @param v1
* @param v2
* @return
*/
public static String returnMin(String v1,String v2){
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.min(b2).toString();
}

/**
* 返回较大数
* @autor:chenming
* @data:2014年9月15日
*
* @param v1
* @param v2
* @return
*/
public static String returnMax(String v1,String v2){
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.max(b2).toString();
}
}
Loading

0 comments on commit eda0c84

Please sign in to comment.