int day =Integer.parseInt(date);//要增加的天数,这里将String类型转换为整型 SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//时间的格式 Calendar c = Calendar.getInstance();//用Calendar获取当前时间 String created_time=sf.format(c.getTime());/*获取当前时间 转换为字符串 */ c.add(Calendar.DAY_OF_MONTH, day);//当前时间增加了day天 String end_time=sf.format(c.getTime());/*获取增加后的时间 */ now=sf.parse(end_time);//将增加后的时间给now now是Date类型变量
java中利用calendar进行天数的增加后如何传递给date的解决方法
最新推荐文章于 2024-01-24 23:45:59 发布