zl程序教程

您现在的位置是:首页 >  后端

当前栏目

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

JAVA 获取 时间 当前 几天
2023-09-14 09:03:39 时间
 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));