Commit 7ff3f427ba75b73a6e5652bc19818b0aa8e441bd
Exists in
master
and in
8 other branches
Merge remote-tracking branch 'origin/master'
Showing 1 changed file
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
7ff3f42
... | ... | @@ -406,22 +406,17 @@ |
406 | 406 | int day = daysBetween(birth,checkDate); |
407 | 407 | return day+"天"; |
408 | 408 | } |
409 | -// rightNow = Calendar.getInstance(); | |
410 | -// rightNow.setTime(checkDate); | |
411 | -// rightNow.add(Calendar.MONTH,1); | |
412 | -// rightNow.add(Calendar.YEAR,-1); | |
409 | + Calendar rightNow1 = Calendar.getInstance(); | |
410 | + rightNow1.setTime(checkDate); | |
411 | + rightNow1.add(Calendar.YEAR,-1); | |
413 | 412 | |
414 | - rightNow = Calendar.getInstance(); | |
415 | - rightNow.setTime(checkDate); | |
416 | -// rightNow.add(Calendar.MONTH,1); | |
417 | - rightNow.add(Calendar.YEAR,-1); | |
418 | 413 | |
419 | - | |
420 | - if (birth.getTime() > rightNow.getTime().getTime()) | |
414 | + if (birth.getTime() > rightNow1.getTime().getTime()) | |
421 | 415 | { |
422 | - int month = getMonthSpace(birth,checkDate); | |
423 | 416 | |
417 | + int year = getYearSpace(birth, checkDate); | |
424 | 418 | |
419 | + int month = getMonthSpace(birth,checkDate); | |
425 | 420 | Calendar yearNow = Calendar.getInstance(); |
426 | 421 | yearNow.setTime(birth); |
427 | 422 | yearNow.add(Calendar.MONTH,month); |
428 | 423 | |
... | ... | @@ -484,8 +479,12 @@ |
484 | 479 | c2.setTime(date2); |
485 | 480 | |
486 | 481 | result = c2.get(Calendar.MONDAY) - c1.get(Calendar.MONTH); |
482 | + if (result < 0) | |
483 | + { | |
484 | + result = 12 - Math.abs(result); | |
485 | + } | |
487 | 486 | |
488 | - result = result == 0 ? 1 : Math.abs(result); | |
487 | +// result = result == 0 ? 1 : Math.abs(result); | |
489 | 488 | if (Integer.parseInt(getDD(date1)) > Integer.parseInt(getDD(date2))) |
490 | 489 | { |
491 | 490 | result = result -1; |
... | ... | @@ -616,7 +615,7 @@ |
616 | 615 | System.out.println(new DateTime().minusDays(77));*/ |
617 | 616 | // System.out.println(getDaySeconds()); |
618 | 617 | |
619 | -// String s = getBabyMonthAge(parseYMD("2015-06-07"), new Date()); | |
618 | +// String s = getBabyMonthAge(parseYMD("2015-08-12"), new Date()); | |
620 | 619 | // System.out.println(s); |
621 | 620 | // SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd "); |
622 | 621 | // System.out.println(getBabyAgeMonth(parseYMD("2016-05-23"), new Date())); |
... | ... | @@ -651,6 +650,9 @@ |
651 | 650 | // SimpleDateFormat md = new SimpleDateFormat("M-d"); |
652 | 651 | // String st = md.format(new Date()); |
653 | 652 | // System.out.print(st); |
653 | + | |
654 | + String s = getBabyMonthAge(parseYMD("2014-07-9"), new Date()); | |
655 | + System.out.println(s); | |
654 | 656 | } catch (Exception e) |
655 | 657 | { |
656 | 658 |