/
@author jerry.chen
@param dateStr
@return 获取当前是礼拜几
/
public static String getCurrentWeekOfMonth(String dateStr) {
String weekStr = ;
int year = 0, month = 0, day = 0;
try {
String[] year_month_day = dateStr.split(-);
if (!.equals(year_month_day[0])) {
year = Integer.parseInt(year_month_day[0]);
}
if (!.equals(year_month_day[1])) {
month = Integer.parseInt(year_month_day[1]);
}
if (!.equals(year_month_day[2])) {
day = Integer.parseInt(year_month_day[2]);
}
Calendar calendar = new GregorianCalendar(year, month - 1, day);
if (礼拜天.equals(getCurrentWeekOfMonth(calendar))) {
weekStr = 1;
}
} catch (Exception e) {
e.printStackTrace();
}
return weekStr;
}
/
@author jerry.chen
@param calendar
@return 获取当前是礼拜几;
/
public static String getCurrentWeekOfMonth(Calendar calendar) {
String strWeek = ;
int dw = calendar.get(Calendar.DAY_OF_WEEK);
if (dw == 1) {
strWeek = 礼拜天;
} else if (dw == 2) {
strWeek = 礼拜一;
} else if (dw == 3) {
strWeek = 礼拜二;
} else if (dw == 4) {
strWeek = 礼拜三;
} else if (dw == 5) {
strWeek = 礼拜四;
} else if (dw == 6) {
strWeek = 礼拜五;
} else if (dw == 7) {
strWeek = 礼拜六;
}
return strWeek;
}
/
@author jerry.chen
@param calendar
@return 返回当前是礼拜几;
/
public static int getCurrentWeekOfMonthIndex(Calendar calendar) {
// System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
return calendar.get(Calendar.DAY_OF_WEEK);
}