"ヾ(◍°∇°◍)ノ゙加油哟~","愿我们不负昭华,以梦为马!","愿我们历尽千帆,归来仍是少年!"

java获取这周的开始时间

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);
	}

  

posted @ 2022-03-01 14:31  深夜独行侠  阅读(446)  评论(0编辑  收藏  举报