java 时间 运算

阅读 47

2022-03-15

  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)

0 0 举报