Commit b27b0c36531dd6203174c647ef1be77c6aecf786

Authored by jiangjiazhi
1 parent d1e15f9d93

修改新电子病历

Showing 1 changed file with 34 additions and 6 deletions

platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java View file @ b27b0c3
... ... @@ -47,13 +47,41 @@
47 47 }
48 48  
49 49 public static Integer getAge(Date birth) {
50   - if (birth == null) {
51   - return null;
  50 +
  51 + java.util.Calendar calendar= Calendar.getInstance();
  52 + Date date=new Date();
  53 + calendar.setTime(date);
  54 +
  55 + Calendar c1 = Calendar.getInstance();
  56 + Calendar c2 = Calendar.getInstance();
  57 + c1.setTime(date);
  58 + c2.setTime(birth);
  59 + int year1 = c1.get(Calendar.YEAR);
  60 + int year2 = c2.get(Calendar.YEAR);
  61 +
  62 + int mouth1 = c1.get(Calendar.MONTH);
  63 + int mouth2 = c2.get(Calendar.MONTH);
  64 + int i=0;
  65 + if(mouth1-mouth2>=0){
  66 + int days1 = c1.get(Calendar.DAY_OF_MONTH);
  67 + int days2 = c2.get(Calendar.DAY_OF_MONTH);
  68 + if(days1<days2){
  69 + i=i-1;
  70 + }else if(days1>days2){
  71 + }
  72 + }else if(mouth1-mouth2<0){
  73 + i=i-1;
52 74 }
53   - Date now = new Date();
54   - long m = now.getTime() - birth.getTime();
55   - Long age = m / 31536000000L;
56   - return age.intValue();
  75 +
  76 +
  77 +// if (birth == null) {
  78 +// return null;
  79 +// }
  80 +// Date now = new Date();
  81 +// long m = now.getTime() - birth.getTime();
  82 +// Long age = m / 31536000000L;
  83 +// return age.intValue();
  84 + return (Math.abs(year1 - year2)+i);
57 85 }
58 86 public static Integer getAge(Date birth,Date fmDate) {
59 87 if (birth == null) {