package com.fdkankan.common.util;

import java.util.Date;
import java.util.GregorianCalendar;

public class DateExtUtil {

    public static final String dateStyle = "yyyy-MM-dd HH:mm:ss";
    public static final String dateStyle2 = "HH:mm:ss";
    public static final String dateStyle3 = "HH:mm";
    public static final String dateStyle4 = "yyyy-MM-dd";
    public static final String dateStyle5 = "yyyy-MM";
    public static final String dateStyle6 = "yyyyMMdd";
    public static final String dateStyle7 = "yyMMddHHmm";
    public static final String dateStyle8 = "yyyy-MM-dd HH:mm";
    public static final String dateStyle9 = "yyyy.MM.dd";

    public static Date hoursCalculate(Date beginDate, int hours) {
        return timesCalculate(beginDate, hours, GregorianCalendar.HOUR);
    }

    public static Date timesCalculate(Date beginDate, int times, int type) {
        /*
         * GregorianCalendar类的add(int field,int amount)方法表示年月日加减.
         * field参数表示年,月,周,日等. amount参数表示要加减的数量.
         */
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(beginDate);
        gc.add(type, times);
        return gc.getTime();
    }

}
