forked from fanruan/finekit
richie
5 years ago
8 changed files with 149 additions and 15 deletions
@ -0,0 +1,38 @@
|
||||
package com.fanruan.api.report; |
||||
|
||||
import com.fr.stable.unit.UNIT; |
||||
import com.fr.stable.unit.UnitUtils; |
||||
|
||||
public class UnitKit { |
||||
|
||||
/** |
||||
* 数值转化成英尺单位 |
||||
* |
||||
* @param doubleString |
||||
* @return 转化后的单位 |
||||
*/ |
||||
public static UNIT unit4CompatibleInchDV(String doubleString) { |
||||
return UnitUtils.unit4CompatibleInchDV(doubleString); |
||||
} |
||||
|
||||
/** |
||||
* 数值转化成毫米单位 |
||||
* |
||||
* @param doubleString |
||||
* @return 转化后的单位 |
||||
*/ |
||||
public static UNIT unit4CompatibleMMDV(String doubleString) { |
||||
return UnitUtils.unit4CompatibleMMDV(doubleString); |
||||
} |
||||
|
||||
/** |
||||
* 两个单位相减取绝对值 |
||||
* |
||||
* @param a 单位a |
||||
* @param b 单位b |
||||
* @return 两个单位差值的绝对值 |
||||
*/ |
||||
public static UNIT abs(UNIT a, UNIT b) { |
||||
return UnitUtils.abs(a, b); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fanruan.api.report; |
||||
|
||||
import com.fr.stable.unit.FU; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class UnitKitTest { |
||||
|
||||
@Test |
||||
public void unit4CompatibleInchDV() { |
||||
String str1 = "100"; |
||||
Assert.assertEquals(UnitKit.unit4CompatibleInchDV(str1), FU.getInstance(365760000)); |
||||
} |
||||
|
||||
@Test |
||||
public void unit4CompatibleMMDV() { |
||||
String str1 = "100"; |
||||
Assert.assertEquals(UnitKit.unit4CompatibleMMDV(str1), FU.getInstance(14400000)); |
||||
} |
||||
} |
Loading…
Reference in new issue