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


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);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM