String day = "2012-10-19";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
try {
date = sdf.parse(day);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance(); //得到日历
calendar.setTime(date);//把当前时间赋给日历
calendar.add(Calendar.DAY_OF_MONTH, +1); //设置为后一天
String day2 = sdf.format(calendar.getTime());
本文详细介绍了如何在Java中使用SimpleDateFormat进行日期格式转换、日期解析与日期加减操作,通过实例展示了日期时间处理的基本步骤与技巧。
7325

被折叠的 条评论
为什么被折叠?



