根据指定的日期字符串获取星期几

	/**
	 * <pre>
	 * 根据指定的日期字符串获取星期几
	 * </pre>
	 * 
	 * @param strDate 指定的日期字符串(yyyy-MM-dd 或 yyyy/MM/dd)
	 * @return week
	 *         星期几(MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY,SUNDAY)
	 */
	public static String getWeekByDateStr(String strDate)
	{
		int year = Integer.parseInt(strDate.substring(0, 4));
		int month = Integer.parseInt(strDate.substring(5, 7));
		int day = Integer.parseInt(strDate.substring(8, 10));

		Calendar c = Calendar.getInstance();

		c.set(Calendar.YEAR, year);
		c.set(Calendar.MONTH, month - 1);
		c.set(Calendar.DAY_OF_MONTH, day);

		String week = "";
		int weekIndex = c.get(Calendar.DAY_OF_WEEK);

		switch (weekIndex)
		{
		case 1:
			week = "SUNDAY";
			break;
		case 2:
			week = "MONDAY";
			break;
		case 3:
			week = "TUESDAY";
			break;
		case 4:
			week = "WEDNESDAY";
			break;
		case 5:
			week = "THURSDAY";
			break;
		case 6:
			week = "FRIDAY";
			break;
		case 7:
			week = "SATURDAY";
			break;
		}
		return week;
	}

根据指定的日期字符串获取星期几

上一篇:GetModuleFileName 64位问题


下一篇:云计算井喷蓄势以待