0
点赞
收藏
分享

微信扫一扫

java 时间 运算

崭新的韭菜 2022-03-15 阅读 47
  1. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

  2. Date nowDate = new Date();

  3. System.out.print("当前日期" + sdf.format(nowDate));

  4. System.out.println(" "+nowDate);

  5. //5分钟化为毫秒

  6. long fiveMinutes = 5 * 60 * 1000;

  7. System.out.println(fiveMinutes);

  8. nowDate.setTime(nowDate.getTime() - fiveMinutes);

  9. String strTime = sdf.format(nowDate);

  10. System.out.print("当前日期减去五分钟" + strTime);

  11. System.out.println(" "+nowDate)

举报

相关推荐

0 条评论