List of utility methods to do Day of Week
int | getWeekOfYear(Date date) get Week Of Year Calendar calendar = getCalendarFromDate(date);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
return calendar.get(Calendar.WEEK_OF_YEAR) - 1;
|
int | getWeekOfYear(Date date) get Week Of Year Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.setFirstDayOfWeek(Calendar.SUNDAY);
cal.setMinimalDaysInFirstWeek(1);
return cal.get(Calendar.WEEK_OF_YEAR);
...
|
String | getWeekOfYear(String date) get Week Of Year String[] tempYear = date.trim().split("-"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, Integer.valueOf(tempYear[0])); cal.set(Calendar.MONTH, (Integer.valueOf(tempYear[1]) - 1)); cal.set(Calendar.DATE, Integer.valueOf(tempYear[2])); int week = cal.get(Calendar.WEEK_OF_YEAR); return String.valueOf(week); |
int | getWeeksBetweenDate(Date begin, Date end) get Weeks Between Date int bWeek = getDateField(begin, Calendar.WEEK_OF_YEAR); int eWeek = getDateField(end, Calendar.WEEK_OF_YEAR); return eWeek - bWeek; |
Date | getWeekStart(Date date) Returns week start date. if (date == null) { return null; Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); ... |
Date | getWeekStart(Date date) get Week Start Calendar calendar = new GregorianCalendar(); calendar.setTime(date); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); return calendar.getTime(); ... |
long | getWeekStartDateBeforeCurrent(int weekNum, Date current) get Week Start Date Before Current Calendar calendar = Calendar.getInstance(); calendar.setTime(current); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); ... |
int | getWeekth(String sDate) get Weekth if (sDate == null || sDate.length() != 8) return -1; Calendar c = Calendar.getInstance(Locale.KOREA); c.set(Integer.parseInt(sDate.substring(0, 4)), Integer.parseInt(sDate.substring(4, 6)) - 1, Integer.parseInt(sDate.substring(6))); GregorianCalendar gc = new GregorianCalendar(Locale.KOREA); gc.setTime(c.getTime()); return c.get(Calendar.WEEK_OF_MONTH); ... |
Integer | getYearOfWeek(Date date) get Year Of Week Date sunday = getSundayOfWeek(date);
return getYear(sunday);
|
java.util.Date | incWeek(java.util.Date date, int amount, Locale locale) inc Week Calendar calendar = Calendar.getInstance(locale);
calendar.setTime(date);
calendar.add(Calendar.WEEK_OF_MONTH, amount);
return calendar.getTime();
|