List of utility methods to do Day of Week
Date | getDayAfterGivenDate(Date date, int dayOfWeek) Find the given day of the week (sunday, monday etc.) that falls before the given date Calendar cal = Calendar.getInstance(); cal.setTime(date); int originalDayOfWeek = cal.get(Calendar.DAY_OF_WEEK); int dayDiff = dayOfWeek - originalDayOfWeek; if (dayDiff <= 0) { dayDiff += 7; cal.add(Calendar.DATE, dayDiff); ... |
String | getDayOfWeek() get Day Of Week String dow = ""; SimpleDateFormat sdf = new SimpleDateFormat("E"); String day = sdf.format(new Date()).toLowerCase(); if (day.equals("sun")) { dow = "1"; } else if (day.equals("mon")) { dow = "2"; } else if (day.equals("tue")) { ... |
int | getDayOfWeek(Date date) get Day Of Week Calendar cal = Calendar.getInstance(); cal.setTime(date); int w = cal.get(Calendar.DAY_OF_WEEK) - 1; if (w < 0) { w = 1; if (w == 0) { w = 7; ... |
int | getDayOfWeek(int _year, int _month, int _day) get Day Of Week int year, month, date; Calendar cal = Calendar.getInstance(); cal.set(_year, _month - 1, _day); return cal.get(Calendar.DAY_OF_WEEK); |
int[] | getDayOfWeek(int year, int month, int day) get Day Of Week int[] rtn = new int[6]; int week = 0; long longDate = 0; java.util.Date date = null; Calendar calendar1 = Calendar.getInstance(); Calendar calendar2 = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, day); ... |
int | getDayOfWeek(int year, int month, int day) get Day Of Week Calendar calendar = Calendar.getInstance(); if (year > -1) { calendar.set(Calendar.YEAR, year); if (month > -1) { month--; calendar.set(Calendar.MONTH, month); if (day > -1) { calendar.set(Calendar.DAY_OF_MONTH, day); return calendar.get(Calendar.DAY_OF_WEEK); |
int | getDayOfWeek(String date, String pattern) get Day Of Week Calendar c = Calendar.getInstance(); int result = -1; SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date d = sdf.parse(date); c.setTime(d); result = c.get(Calendar.DAY_OF_WEEK) - 1; return result; |
int | getDayOfWeek(String datetime) get Day Of Week Calendar cal = Calendar.getInstance();
cal.setTime(parseDate(datetime));
return cal.get(Calendar.DAY_OF_WEEK) - 1;
|
Integer | getDayOfWeek(String f) get Day Of Week Integer dayOfWeek; try { SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy"); Date dt1 = format1.parse(f); DateFormat format2 = new SimpleDateFormat("u"); dayOfWeek = Integer.valueOf(format2.format(dt1)); } catch (Exception ex) { dayOfWeek = new Integer(-1); ... |
String | getDayOfWeek(String format, int calendarField) get Day Of Week String strDate = null; try { Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format); int week = c.get(Calendar.DAY_OF_WEEK); if (week == calendarField) { strDate = mSimpleDateFormat.format(c.getTime()); } else { ... |