java按照日期获取当前是礼拜几?
添加时间:2013-6-16 点击量:
/
@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);
}
真正的心灵世界会告诉你根本看不见的东西,这东西需要你付出思想和灵魂的劳动去获取,然后它会照亮你的生命,永远照亮你的生命。——王安忆《小说家的十三堂课》
/
@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);
}
真正的心灵世界会告诉你根本看不见的东西,这东西需要你付出思想和灵魂的劳动去获取,然后它会照亮你的生命,永远照亮你的生命。——王安忆《小说家的十三堂课》