Here you can find the source of getAPastDayOfTheWeek(String dayToGet)
public static Date getAPastDayOfTheWeek(String dayToGet)
//package com.java2s; /*//from w ww . j a v a 2s. c o m * Expander: Text Expansion Application * Copyright (C) 2016 Brett Huber * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date getAPastDayOfTheWeek(String dayToGet) { Calendar calendar = new GregorianCalendar(); switch (dayToGet) { case "Monday": calendar.set(2015, Calendar.JUNE, 15); break; case "Tuesday": calendar.set(2015, Calendar.JUNE, 16); break; case "Wednesday": calendar.set(2015, Calendar.JUNE, 17); break; case "Thursday": calendar.set(2015, Calendar.JUNE, 18); break; case "Friday": calendar.set(2015, Calendar.JUNE, 19); break; case "Saturday": calendar.set(2015, Calendar.JUNE, 20); break; case "Sunday": calendar.set(2015, Calendar.JUNE, 21); break; } calendar.set(Calendar.HOUR_OF_DAY, 17); calendar.set(Calendar.MINUTE, 35); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar.getTime(); } }