1.获取当前的年份
SimpleDateFormat df = new SimpleDateFormat("yyyy");
String year = df.format(new Date());
2.获取前3天的日期
Calendar calendar = Calendar.getInstance();
Date date = new Date(System.currentTimeMillis());
calendar.setTime(date);
calendar.add(Calendar.DATE, -3);
date = calendar.getTime();
System.out.println(" ‘"+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date)+" ");
时间: 2024-10-12 20:28:26