获取月的最后一天,开始一天,本周某一天

 /**
     * 获取月的最后一天
     */
    public static String getMonthEnd() {
        final Calendar cal = Calendar.getInstance();
        cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
        final Date date = cal.getTime();
        return CommUtil.parseTimeFormattoDayDate(date);
    }

/**
 * 获取月开始一天
 */
public static String getMonthStart() {
    final Calendar cal = Calendar.getInstance();
    cal.getActualMaximum(Calendar.DAY_OF_MONTH);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    final Date date = cal.getTime();
    return CommUtil.parseTimeFormattoDayDate(date);
}

/**
 * 获取本周某一天 value: Calendar.SUNDAY Calendar.MONDAY Calendar.TUESDAY
 * Calendar.WEDNESDAY Calendar.THURSDAY Calendar.FRIDAY Calendar.SATURDAY
 */
public static String getWeekDay(int value) {
    final Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_WEEK, value);
    final Date date = cal.getTime();
    return CommUtil.parseTimeFormattoDayDate(date);
}
上一篇:Java 中的日期和时间


下一篇:Java时间处理 Date Calendar SimpleDateFormat的运算