Java examples for java.util:Day
find Nearest Previous Monday
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static void main(String[] argv) throws Exception { Date actual = new Date(); System.out.println(findNearestPrevMonday(actual)); }//w w w. ja v a2s . c o m private static Calendar calendar; public static Date findNearestPrevMonday(Date actual) { calendar.setTime(actual); while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { calendar.add(Calendar.DATE, -1); } return calendar.getTime(); } }