歪歪歪日

导航

根据开始时间和周期计算结束时间(一个月,两个月,三个月为周期)

String visitDate=hypertensionVisit.getVisitDate();
System.out.println(visitDate);
Calendar cal = Calendar.getInstance();
Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
date = sdf.parse(visitDate);
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
}
cal.setTime(date);

String period = hypertensionVisit.getPeriod();

if ("3个月".equals(period)) {
cal.add(Calendar.MONTH, 3);

}else if("2个月".equals(period)){
cal.add(Calendar.MONTH, 2);
}
else {
cal.add(Calendar.MONTH, 1);
}
Date date2 = cal.getTime();

String nextDate = sdf.format(date2);

String newNextDate = nextDate.replace(" ", "T");
hypertensionVisit.setNextDate(newNextDate);

posted on 2019-11-12 09:37  妲你小己己  阅读(1050)  评论(0编辑  收藏  举报