List of utility methods to do Week Day
String | getPreviousMonday(Date date, int days) get Previous Monday int weeks = -1; GregorianCalendar currentDate = new GregorianCalendar(); currentDate.setTime(date); currentDate.add(GregorianCalendar.DATE, days + 7 * weeks); Date monday = currentDate.getTime(); DateFormat df = DateFormat.getDateInstance(); String preMonday = df.format(monday); return preMonday; ... |
String | getPreviousOrNextDay(String time, int dayNum) get Previous Or Next Day SimpleDateFormat df = new SimpleDateFormat(DEFAULT_FORMAT_NOHOUR); Date date = df.parse(time); GregorianCalendar currentDate = new GregorianCalendar(); currentDate.setTime(date); currentDate.add(GregorianCalendar.DATE, dayNum); Date monday = currentDate.getTime(); String preMonday = df.format(monday); return preMonday; ... |
Date | getPreWeekLastDay() get Pre Week Last Day Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.setFirstDayOfWeek(1); int week = calendar.get(Calendar.DAY_OF_WEEK); int day = calendar.get(Calendar.DAY_OF_MONTH); calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), day + 1 - week); return calendar.getTime(); |
String | getShortWeekday(int dayOfWeek) Returns the short name of the weekday. return getShortWeekday(dayOfWeek, Locale.getDefault());
|
String | getShortWeekday(String day) Get short day string for current locale DateFormatSymbols symbols; String[] defaultDays; String[] Days; symbols = new DateFormatSymbols(new Locale("en", "US")); defaultDays = symbols.getShortWeekdays(); symbols = new DateFormatSymbols(); Days = symbols.getShortWeekdays(); int i = 0; ... |
String | getSQLForWeekSunday(String weekString) getSQLForWeekSunday: sql for sunday SimpleDateFormat sdf = new SimpleDateFormat("yyyy-ww", new Locale("de", "DE")); java.util.Date startDate = getNextSunday(sdf.parse(weekString)); SimpleDateFormat sdfOutput = new SimpleDateFormat("dd.MM.yyyy"); return "to_date('" + sdfOutput.format(startDate) + "','DD.MM.YYYY')"; |
String | getSundayOfWeek() get Sunday Of Week Calendar c = Calendar.getInstance(); java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd"); c.setFirstDayOfWeek(Calendar.MONDAY); c.set(Calendar.DAY_OF_WEEK, 1); return df.format(c.getTime()); |
Date | getThisWeekMonday() get This Week Monday Calendar cal = Calendar.getInstance();
cal.setTime(getTodayZero());
cal.set(Calendar.DAY_OF_WEEK, 2);
return cal.getTime();
|
int | getTodayOfWeek() get Today Of Week calendar = Calendar.getInstance(); int dayOfWeekChina = calendar.get(calendar.DAY_OF_WEEK) - 1; return dayOfWeekChina; |
String | getWeek(Date today, int index, String format) get Week Calendar calendar = Calendar.getInstance(); calendar.setTime(today); ArrayList<Date> list = getWeekDateList(today, 0); Date d = calendar.getTime(); for (Date date : list) { Calendar c = Calendar.getInstance(); c.setTime(date); if (c.get(Calendar.DAY_OF_WEEK) == index + 1) { ... |