Commit bac67218547ae095199d7bcd93fb59928b7f0aae

Authored by jiangjiazhi
1 parent 265c3f8e2a

修改新电子病历

Showing 1 changed file with 25 additions and 2 deletions

platform-common/src/main/java/com/lyms/platform/common/utils/StringUtils.java View file @ bac6721
1 1 package com.lyms.platform.common.utils;
2 2  
  3 +import org.apache.commons.lang.math.*;
  4 +import org.apache.commons.lang.math.NumberUtils;
  5 +
3 6 import java.util.Date;
4 7  
5 8 /**
6 9  
7 10  
... ... @@ -36,17 +39,37 @@
36 39 if (StringUtils.isEmpty(babyWeight)) {
37 40 return babyWeight;
38 41 }
  42 +
  43 + /* if(babyWeight.indexOf('.')>-1){
  44 + Double doubl= NumberUtils.toDouble(babyWeight);
  45 + return doubl/1000+"";
  46 + }else{
  47 + Integer integer=NumberUtils.toInt(babyWeight);
  48 + return ((Double)integer/1000)+"";
  49 + }*/
  50 + /* */
  51 + int index = babyWeight.indexOf('.');
  52 + if(index>-1){
  53 + babyWeight = babyWeight.substring(0,index);
  54 + }
  55 +
  56 + if(babyWeight.length()>=4 &&index>-1 &&index<5){
  57 + babyWeight=babyWeight.substring(0,4);
  58 + }
39 59 if (babyWeight.length() <= 3) {
40 60 babyWeight = org.apache.commons.lang.StringUtils.leftPad(babyWeight, 4, "0");
41 61 }
42 62 StringBuilder stringBuilder = new StringBuilder(babyWeight);
43   - if (babyWeight.length() > 2) {
  63 +
  64 + if (babyWeight.length() > 2) {
44 65 stringBuilder.setLength(babyWeight.length() - 1);
45 66 }
46 67 stringBuilder.insert(stringBuilder.length() - 2, ".");
47 68 return stringBuilder.toString();
48 69 }
49   -
  70 + public static void main(String[] args){
  71 + System.out.println(cutBabyWeight("5000.1"));
  72 + }
50 73 public static Object isEmpty(Object obj, Object defaultVal) {
51 74 if (null == obj) {
52 75 return defaultVal;