List of utility methods to do Week Day
String[] | getBothDayOfWeek(String str, int week) get Both Day Of Week return new String[] { getFirstDayOfWeek(str, week), getLastDayOfWeek(str, week) }; |
int | getCurrentDayOfWeekArabia() Method: get current day of week in Arabia return type int Calendar calendar = Calendar.getInstance(Locale.getDefault());
return calendar.get(Calendar.DAY_OF_WEEK);
|
String | getCurrentDayOfWeekEnglish() Method: get current day of week in English return type String String[] dayOfWeek = { "Sunday", "Monday", "Tuseday", "Wednesday", "Thursday", "Friday", "Saturday" }; return dayOfWeek[getCurrentDayOfWeekArabia() - 1]; |
int | getCurWeek(String day) get Cur Week SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date date = null; if (day != null) { try { date = format.parse(day); } catch (ParseException e) { e.printStackTrace(); } else { date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTime(date); return calendar.get(Calendar.WEEK_OF_YEAR); |
int | getCurWeekDayByStr(String curday) get Cur Week Day By Str try { java.util.Date date = str2date(curday); Calendar rightNow = Calendar.getInstance(); rightNow.setTime(date); return rightNow.get(Calendar.DAY_OF_WEEK); } catch (Exception e) { e.printStackTrace(); return 1; ... |
int | getCurWeekDayByStr(String curday) get Cur Week Day By Str try { java.util.Date date = str2utilDate(curday); Calendar rightNow = Calendar.getInstance(); rightNow.setTime(date); int week = rightNow.get(Calendar.DAY_OF_WEEK); return week; } catch (Exception e) { System.out.println("DateUtil.getYearWeek(str) Error:e = " + e); ... |
long | getDay(long date, int startOfWeek, int increment) get Day Calendar calendar = CALENDAR; synchronized (calendar) { calendar.setTimeInMillis(date); int day = calendar.get(Calendar.DAY_OF_WEEK); while (day != startOfWeek) { calendar.add(Calendar.DATE, increment); day = calendar.get(Calendar.DAY_OF_WEEK); return startOfDayInMillis(calendar.getTimeInMillis()); |
String | getDayNextWeek() get Day Next Week Calendar cal = new GregorianCalendar(); cal.roll(Calendar.DAY_OF_YEAR, +7); return String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); |
int | getDayOfTheWeekFromNow(int nDays) Returns the day of week, 'nDays' from today GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.DAY_OF_YEAR, nDays); return cal.get(Calendar.DAY_OF_WEEK); |
int | getDayOfWeek() get Day Of Week Calendar date = Calendar.getInstance(Locale.US);
return date.get(Calendar.DAY_OF_WEEK);
|