确定时间格式
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date currentTime = new Date();
Date类型转换成String类型
String dateString = sdf.format(currentTime);
String类型转换成Date类型
Date date = sdf.parse(dateString);
calendar 用法实例
Calendar calendar = Calendar.getInstance();
calendar.setTime(sdf.parse(Btime));
calendar.add(Calendar.DATE, 5);//在calendar加5天,如果是-5就是在calendar减5天
String time = sdf.format(calendar.getTime());//将Date类型转换成String类型