ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Java 获取当前时间的前几天或后几天

2022-07-11 16:07:04  阅读:50  来源: 互联网

标签:Java Date 几天 SimpleDateFormat 获取 date new calendar Calendar


 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
     Date date=new Date();  
     Calendar calendar = Calendar.getInstance();  
     calendar.setTime(date);  
     calendar.add(Calendar.DAY_OF_MONTH, -1);  
     date = calendar.getTime();  
     System.out.println(sdf.format(date)); 

 

标签:Java,Date,几天,SimpleDateFormat,获取,date,new,calendar,Calendar
来源: https://www.cnblogs.com/austinspark-jessylu/p/16466723.html

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有