List of utility methods to do Week of Year
int | getWeekOfPreYearWeek(int year, int week) get Week Of Pre Year Week return week == 1 ? getMaxWeekNumOfYear(year) : week - 1;
|
String | getWeekOfYear() get Week Of Year String num = Calendar.getInstance().get(Calendar.WEEK_OF_YEAR) + ""; return num.length() == 1 ? "0" + num : num; |
int | getWeekOfYear(String year, String month, String day) get Week Of Year Calendar cal = new GregorianCalendar(); cal.clear(); cal.set(new Integer(year).intValue(), new Integer(month).intValue() - 1, new Integer(day).intValue()); return cal.get(Calendar.WEEK_OF_YEAR); |
int | getWeekOfYearByDay(String year, String month, String day) get Week Of Year By Day Calendar calendar = Calendar.getInstance(Locale.UK);
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setMinimalDaysInFirstWeek(4);
calendar.set(Calendar.YEAR, Integer.parseInt(year));
calendar.set(Calendar.MONTH, Integer.parseInt(month) - 1);
calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day));
long milltimes = calendar.getTimeInMillis();
calendar.setTimeInMillis(milltimes);
...
|
int | getWeekOfYearFromTimestamp(long ms) get Week Of Year From Timestamp if (ms < 0) throw new NumberFormatException("argument must be positive"); Calendar cal = Calendar.getInstance(TIMEZONE, LOCALE); cal.setTimeInMillis(ms); return cal.get(Calendar.WEEK_OF_YEAR); |