确定时间格式

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类型

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2022-01-07
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案