SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // HH 为24小时制 hh 为12小时制
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE, -30);//根据实际需要修改
Date date = calendar.getTime();
System.out.println(tempDate.format(date));
本文介绍如何使用Java的SimpleDateFormat和Calendar类来获取当前日期往前推30天的具体日期,并将该日期以yyyy-MM-dd HH:mm:ss的格式输出。
2362

被折叠的 条评论
为什么被折叠?



