public static void main(String[] args) { Calendar c=Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); //今天 String today=df.format("今天时间:"+c.getTime()); System.out.println(today); //今天是周几 int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); // dayOfWeek-=2; //今天-1天(昨天) c.add(Calendar.DAY_OF_MONTH, -dayOfWeek); String yesterday=df.format(c.getTime()); System.out.println("周一时间 "+yesterday); System.out.println("今天周几 "+dayOfWeek); }