间隔日期转换成:x天 x月 x年x月
实例:
String confirmDateString = hypertension.getConfirmDate();
LocalDate today = LocalDate.now();
LocalDate confirmDate = LocalDate.parse(confirmDateString, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
Period p = Period.between(confirmDate, today);
System.out.println(p);
String result = "";
if (p.getDays() > 0) {
result = p.getDays() + "天";
}
if (p.getMonths() > 0) {
result = p.getMonths() + "月";
}
if (p.getYears() > 0) {
result = p.getYears() + "年" + p.getMonths() + "月";
}
hypertension.setDeaseAge(result);
}