當前位置: 首頁>>代碼示例>>Java>>正文


Java DateUtils.addMonths方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.time.DateUtils.addMonths方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.addMonths方法的具體用法?Java DateUtils.addMonths怎麽用?Java DateUtils.addMonths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.time.DateUtils的用法示例。


在下文中一共展示了DateUtils.addMonths方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showNextMonth

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public void showNextMonth() {
    firstDayOfMonth = DateUtils.addMonths(firstDayOfMonth, 1);
    updateCalendarRange();
}
 
開發者ID:cuba-platform,項目名稱:sample-timesheets,代碼行數:5,代碼來源:CalendarScreen.java

示例2: clearLog

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@RequestMapping("/clearLog")
@ResponseBody
public ReturnT<String> clearLog(int jobGroup, int jobId, int type){

	Date clearBeforeTime = null;
	int clearBeforeNum = 0;
	if (type == 1) {
		clearBeforeTime = DateUtils.addMonths(new Date(), -1);	// 清理一個月之前日誌數據
	} else if (type == 2) {
		clearBeforeTime = DateUtils.addMonths(new Date(), -3);	// 清理三個月之前日誌數據
	} else if (type == 3) {
		clearBeforeTime = DateUtils.addMonths(new Date(), -6);	// 清理六個月之前日誌數據
	} else if (type == 4) {
		clearBeforeTime = DateUtils.addYears(new Date(), -1);	// 清理一年之前日誌數據
	} else if (type == 5) {
		clearBeforeNum = 1000;		// 清理一千條以前日誌數據
	} else if (type == 6) {
		clearBeforeNum = 10000;		// 清理一萬條以前日誌數據
	} else if (type == 7) {
		clearBeforeNum = 30000;		// 清理三萬條以前日誌數據
	} else if (type == 8) {
		clearBeforeNum = 100000;	// 清理十萬條以前日誌數據
	} else if (type == 9) {
		clearBeforeNum = 0;			// 清理所有日誌數據
	} else {
		return new ReturnT<String>(ReturnT.FAIL_CODE, "清理類型參數異常");
	}

	xxlJobLogDao.clearLog(jobGroup, jobId, clearBeforeTime, clearBeforeNum);
	return ReturnT.SUCCESS;
}
 
開發者ID:mmwhd,項目名稱:stage-job,代碼行數:32,代碼來源:JobLogController.java

示例3: clearLog

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
@RequestMapping("/clearLog")
@ResponseBody
public ReturnT<String> clearLog(int jobGroup, int jobId, int type){

	Date clearBeforeTime = null;
	int clearBeforeNum = 0;
	if (type == 1) {
		clearBeforeTime = DateUtils.addMonths(new Date(), -1);	// 清理一個月之前日誌數據
	} else if (type == 2) {
		clearBeforeTime = DateUtils.addMonths(new Date(), -3);	// 清理三個月之前日誌數據
	} else if (type == 3) {
		clearBeforeTime = DateUtils.addMonths(new Date(), -6);	// 清理六個月之前日誌數據
	} else if (type == 4) {
		clearBeforeTime = DateUtils.addYears(new Date(), -1);	// 清理一年之前日誌數據
	} else if (type == 5) {
		clearBeforeNum = 1000;		// 清理一千條以前日誌數據
	} else if (type == 6) {
		clearBeforeNum = 10000;		// 清理一萬條以前日誌數據
	} else if (type == 7) {
		clearBeforeNum = 30000;		// 清理三萬條以前日誌數據
	} else if (type == 8) {
		clearBeforeNum = 100000;	// 清理十萬條以前日誌數據
	} else if (type == 9) {
		clearBeforeNum = 0;			// 清理所用日誌數據
	} else {
		return new ReturnT<String>(ReturnT.FAIL_CODE, "清理類型參數異常");
	}

	xxlJobLogDao.clearLog(jobGroup, jobId, clearBeforeTime, clearBeforeNum);
	return ReturnT.SUCCESS;
}
 
開發者ID:kevinKaiF,項目名稱:xxl-job,代碼行數:32,代碼來源:JobLogController.java

示例4: provisionBillingCycle

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private void provisionBillingCycle(BillingPkgVO billPkgVO, UserVO userVO, Integer numberOfMonths,
                                   Boolean provisionForTrial, BillingLogType billingLogType) throws CoreException {
    myLog.info("Provision new BillingCycle for user:" + userVO.getUserid()
            + ",market:" + userVO.getMarketVO().getName()
            + ", billingPackage" + billPkgVO.getPkgName()
            + ", qty->" + numberOfMonths);
    BillingCycleVO billCycleVO;
    userVO.setPackageVO(billPkgVO);

    BillingCycleVO userLatestBillCycleVO = getUserLatestBillCycleVO(userVO);
    if (userLatestBillCycleVO != null &&
            userLatestBillCycleVO.getBillingPkgVO().getPkgName().equalsIgnoreCase(billPkgVO.getPkgName()) &&
            !provisionForTrial) {
        // Since it is same bill Package, we will just extends user's current BillCycle;
        Date todayDate = new Date();
        Date newEndDate = DateUtils.addMonths(userLatestBillCycleVO.getEndDate(), numberOfMonths);
        if(todayDate.after(newEndDate)) {
            newEndDate = DateUtils.addMonths(todayDate, numberOfMonths);
        }
        billCycleVO = extendCurrentBillCycle(userLatestBillCycleVO, newEndDate, numberOfMonths);
    } else {
        if (provisionForTrial) {
            billCycleVO = createNewBillCycleWithTrial(userVO);
        } else {
            billCycleVO = createNewBillCycleByMonth(userVO, numberOfMonths);
        }

        myLog.debug("BillCycleVO->" + billCycleVO);
        billingCycleDAO.create(billCycleVO);
        myLog.debug("Billing Log Inserted for->" + userVO.getUserid());
    }

    String billingLogRemark = "BillPkg:" + billPkgVO.getPkgName() + " Months:" + numberOfMonths;
    insertNewBillingLog(userVO, null, billCycleVO, 0, 0, billingLogType, billingLogRemark);
    getUserDAO().update(userVO);
}
 
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:37,代碼來源:DefaultBillingManager.java

示例5: createNewBillCycleByMonth

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private BillingCycleVO createNewBillCycleByMonth(UserVO userVO, Integer numberOfMonth) throws CoreException {
    Date startDate = new Date();
    Date endDate;
    if (!userVO.getPackageVO().isRenewable() &&
            userVO.getPackageVO().getTrialPeriod() > 0) {
        endDate = DateUtils.addDays(startDate, userVO.getPackageVO().getTrialPeriod());
    } else {
        endDate = DateUtils.addMonths(startDate, numberOfMonth);
    }
    return createNewBillCycle(userVO, startDate, endDate, numberOfMonth);
}
 
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:12,代碼來源:DefaultBillingManager.java

示例6: prepareCreateRecurringProfileReq

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private String prepareCreateRecurringProfileReq(String paypalToken, String payerid, String payerEmail,
            UserVO userVO,
            Integer noBillCycles,
            String productCode,
            String productDesc,
            Double productPrice) throws PayPalException {

        NVPEncoder encoder = new NVPEncoder();
        encoder.add(NVP_METHOD_KEY, CREATE_SUBSCRIPTION_PROFILE_METHOD_NAME);
        encoder.add(NVP_TOKEN_KEY, paypalToken);
        // Unit Invoice id to identified the subscription profile
        // We will use user's activation code + "_____" + pricingPkgCode as unique
        // invoice id
        encoder.add("PROFILEREFERENCE", userVO.getActivationCode() + "_____" + productCode
                + "_____" + new Date().getTime());
//        encoder.add("DESC", getPaypalPkgDesc(pkgVO));
        encoder.add("DESC", productDesc);
//
        Date profileStartDate = DateUtils.addMonths(new Date(), noBillCycles);
        String profileStartDateStr = dateFormat.format(profileStartDate) + "T00:00:00";
        encoder.add("BILLINGPERIOD", "Month");
        
        encoder.add("BILLINGFREQUENCY", noBillCycles.toString());
        encoder.add("PROFILESTARTDATE", profileStartDateStr);
        encoder.add("AMT", productPrice.toString());
        encoder.add("EMAIL", payerEmail);
        encoder.add("L_PAYMENTREQUEST_0_ITEMCATEGORY0", "Digital");
        encoder.add("L_PAYMENTREQUEST_0_NAME0", productCode);
        encoder.add("L_PAYMENTREQUEST_0_AMT0", productPrice.toString());
        encoder.add("CURRENCYCODE", "USD");
        encoder.add("L_PAYMENTREQUEST_0_QTY0", "1");

        return encoder.encode();
    }
 
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:35,代碼來源:PaypalGW.java

示例7: prepareCreateRecurringProfileReqForGifting

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
private String prepareCreateRecurringProfileReqForGifting(String paypalToken, String payerid, String payerEmail,
    		GiftPaymentLogVO giftPaymentLogVO,
            Integer noBillCycles,
            String productCode,
            String productDesc,
            Double productPrice) throws PayPalException {

        NVPEncoder encoder = new NVPEncoder();
        encoder.add(NVP_METHOD_KEY, CREATE_SUBSCRIPTION_PROFILE_METHOD_NAME);
        encoder.add(NVP_TOKEN_KEY, paypalToken);
        // Unit Invoice id to identified the gifting profile
        // We will use user's country calling + mobile number + "_____" + pricingPkgCode as unique
        // invoice id
        encoder.add("PROFILEREFERENCE", "GIFT_" + giftPaymentLogVO.getMobileCountry().getIso()
        		+ "-" + giftPaymentLogVO.getMobileNumber()
        		+ "_____" + productCode
                + "_____" + new Date().getTime());
//        encoder.add("DESC", getPaypalPkgDesc(pkgVO));
        encoder.add("DESC", productDesc);
//
        Date profileStartDate = DateUtils.addMonths(new Date(), noBillCycles);
        String profileStartDateStr = dateFormat.format(profileStartDate) + "T00:00:00";
        encoder.add("BILLINGPERIOD", "Month");
        
        encoder.add("BILLINGFREQUENCY", noBillCycles.toString());
        encoder.add("PROFILESTARTDATE", profileStartDateStr);
        encoder.add("AMT", productPrice.toString());
        encoder.add("EMAIL", payerEmail);
        encoder.add("L_PAYMENTREQUEST_0_ITEMCATEGORY0", "Digital");
        encoder.add("L_PAYMENTREQUEST_0_NAME0", productCode);
        encoder.add("L_PAYMENTREQUEST_0_AMT0", productPrice.toString());
        encoder.add("CURRENCYCODE", "USD");
        encoder.add("L_PAYMENTREQUEST_0_QTY0", "1");

        return encoder.encode();
    }
 
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:37,代碼來源:PaypalGW.java

示例8: toJSON

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public JSONObject toJSON() {
    JSONObject obj = new JSONObject();
    // JK There are two type of subscription, one with AutoRenew,
    // One with onetime payment, for AutoRenew, it is import that we 
    // put in the next payment date, and auto renew Gateway
    // For onetime payment, we needs to put in the expire date
    //
    try {
        if (this.getEffectiveDate() != null) {
            obj.put(EFFECTIVE_DATE_KEY, this.getEffectiveDate().getTime());
        }

        if(this.getPricePkgVO().isAutoRenew()) {
            if (this.getNextPaymentDate() != null) {
                obj.put(NEXT_PAYMENT_DATE_KEY, this.getNextPaymentDate().getTime());
            }
            obj.put(PAYMENT_GW_NAME_KEY, this.gwName);
        } else {
            Date expireDate = DateUtils.addMonths(this.getEffectiveDate(), this.getPricePkgVO().getQuantity());
            obj.put(EXPIRE_AT_KEY, expireDate.getTime());
        }

        obj.put(PAYMENT_PROFILE_ID_KEY, this.getProfileid());
        if (this.getPricePkgVO() != null) {
            obj.put(PRICE_PKG_CODE_KEY, this.getPricePkgVO().getPricePkgName());
        }

        obj.put(PAYMENT_AMT_KEY, this.getPaymentAmt());
    } catch (JSONException ex) {
        myLog.error("Failed to create JSONObject from: " + this, ex);
    }
    return obj;
}
 
開發者ID:SECQME,項目名稱:watchoverme-server,代碼行數:34,代碼來源:UserSubscriptionInfoVO.java

示例9: showPreviousMonth

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
public void showPreviousMonth() {
    firstDayOfMonth = DateUtils.addMonths(firstDayOfMonth, -1);
    updateCalendarRange();
}
 
開發者ID:cuba-platform,項目名稱:sample-timesheets,代碼行數:5,代碼來源:CalendarScreen.java

示例10: addMonths

import org.apache.commons.lang.time.DateUtils; //導入方法依賴的package包/類
/**
 * 給指定日期加幾個月
 * 
 * @param date
 *            指定的日期
 * @param numMonths
 *            需要往後加的月數
 * @return 加好後的日期
 */
public static Date addMonths(Date date, int numMonths) {
	Assert.notNull(date);
	return DateUtils.addMonths(date, numMonths);
}
 
開發者ID:thinking-github,項目名稱:nbone,代碼行數:14,代碼來源:DateUtil.java


注:本文中的org.apache.commons.lang.time.DateUtils.addMonths方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。