本文整理了Java中org.joda.time.LocalDate.plus()
方法的一些代码示例,展示了LocalDate.plus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.plus()
方法的具体详情如下:
包路径:org.joda.time.LocalDate
类名称:LocalDate
方法名:plus
[英]Returns a copy of this date with the specified period added.
If the amount is zero or null, then this
is returned.
This method is typically used to add complex period instances. Adding one field is best achieved using methods like #plusYears(int).
Unsupported time fields are ignored, thus adding a period of 24 hours will not have any effect.
[中]返回添加了指定期间的此日期的副本。
如果金额为零或空,则返回this
。
此方法通常用于添加复杂的时段实例。添加一个字段最好使用#plusYears(int)等方法。
不支持的时间字段将被忽略,因此添加24小时不会产生任何效果。
代码示例来源:origin: killbill/killbill
@Override
public boolean evaluate(final BillingState state, final LocalDate date) {
LocalDate unpaidInvoiceTriggerDate = null;
if (timeSinceEarliestUnpaidInvoiceEqualsOrExceeds != null && state.getDateOfEarliestUnpaidInvoice() != null) { // no date => no unpaid invoices
unpaidInvoiceTriggerDate = state.getDateOfEarliestUnpaidInvoice().plus(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds.toJodaPeriod());
}
return
(numberOfUnpaidInvoicesEqualsOrExceeds == null || state.getNumberOfUnpaidInvoices() >= numberOfUnpaidInvoicesEqualsOrExceeds) &&
(totalUnpaidInvoiceBalanceEqualsOrExceeds == null || totalUnpaidInvoiceBalanceEqualsOrExceeds.compareTo(state.getBalanceOfUnpaidInvoices()) <= 0) &&
(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds == null ||
(unpaidInvoiceTriggerDate != null && !unpaidInvoiceTriggerDate.isAfter(date))) &&
(responseForLastFailedPayment == null || responseIsIn(state.getResponseForLastFailedPayment(), responseForLastFailedPayment)) &&
(controlTagInclusion == null || isTagIn(controlTagInclusion, state.getTags())) &&
(controlTagExclusion == null || isTagNotIn(controlTagExclusion, state.getTags()));
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testSinglePlan_OnePeriodLessADayAfterStart() throws InvalidDateSequenceException {
final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
final LocalDate targetDate = startDate.plus(getBillingPeriod().getPeriod()).plusDays(-1);
testCalculateNumberOfBillingCycles(startDate, targetDate, 15, ONE);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testSinglePlan_SlightlyMoreThanOnePeriodAfterStart() throws InvalidDateSequenceException {
final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
final LocalDate targetDate = startDate.plus(getBillingPeriod().getPeriod()).plusDays(1);
testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}
代码示例来源:origin: odrotbohm/whoops-architecture
/**
* Extends the {@link Account}'s expiry date by a year.
*/
public void extend() {
this.expiryDate = expiryDate.plus(Years.ONE);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testSinglePlan_CrossingYearBoundary() throws InvalidDateSequenceException {
final LocalDate startDate = invoiceUtil.buildDate(2011, 12, 15);
final LocalDate oneCycleLater = startDate.plus(getBillingPeriod().getPeriod());
// test just before the billing cycle day
testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(-1), 15, ONE);
// test on the billing cycle day
testCalculateNumberOfBillingCycles(startDate, oneCycleLater, 15, TWO);
// test just after the billing cycle day
testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(1), 15, TWO);
}
代码示例来源:origin: odrotbohm/whoops-architecture
/**
* Extends the {@link Account}'s expiry date by a year.
*/
public void extend() {
this.expiryDate = expiryDate.plus(Years.ONE);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testSinglePlan_MovingForwardThroughTime() throws InvalidDateSequenceException {
final LocalDate startDate = invoiceUtil.buildDate(2011, 1, 31);
BigDecimal expectedValue = ONE;
for (int i = 1; i <= 12; i++) {
LocalDate oneCycleLater = startDate;
for (int j = 0; j < i; j++) {
oneCycleLater = oneCycleLater.plus(getBillingPeriod().getPeriod());
}
// test just before the billing cycle day
testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(-1), 31, expectedValue);
expectedValue = expectedValue.add(ONE);
// test on the billing cycle day
testCalculateNumberOfBillingCycles(startDate, oneCycleLater, 31, expectedValue);
// test just after the billing cycle day
testCalculateNumberOfBillingCycles(startDate, oneCycleLater.plusDays(1), 31, expectedValue);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
public static LocalDate advanceByNPeriods(final LocalDate initialDate, final BillingPeriod billingPeriod, final int nbPeriods) {
LocalDate proposedDate = initialDate;
for (int i = 0; i < nbPeriods; i++) {
proposedDate = proposedDate.plus(billingPeriod.getPeriod());
}
return proposedDate;
}
代码示例来源:origin: org.isisaddons.module.fakedata/isis-module-fakedata-dom
@Programmatic
public LocalDate after(final Period period) {
final LocalDate now = fake.clockService.now();
return now.plus(period);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
public LocalDate getNextBillingCycleDate() {
final LocalDate proposedDate = lastBillingCycleDate != null ? lastBillingCycleDate.plus(billingPeriod.getPeriod()) : firstBillingCycleDate;
final LocalDate nextBillingCycleDate = BillCycleDayCalculator.alignProposedBillCycleDate(proposedDate, billingCycleDay, billingPeriod);
return nextBillingCycleDate;
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
public static BigDecimal calculateProRationAfterLastBillingCycleDate(final LocalDate endDate, final LocalDate previousBillThroughDate,
final BillingPeriod billingPeriod) {
// Note: assumption is that previousBillThroughDate is correctly aligned with the billing cycle day
final LocalDate nextBillThroughDate = previousBillThroughDate.plus(billingPeriod.getPeriod());
return calculateProrationBetweenDates(previousBillThroughDate, endDate, previousBillThroughDate, nextBillThroughDate);
}
代码示例来源:origin: spotify/dbeam
public Iterable<String> buildQueries() {
final String limit = this.limit().map(l -> String.format(" LIMIT %d", l)).orElse("");
final String where = this.partitionColumn().flatMap(
partitionColumn ->
this.partition().map(partition -> {
final LocalDate datePartition = partition.toLocalDate();
final String nextPartition = datePartition.plus(partitionPeriod()).toString();
return String.format(" WHERE %s >= '%s' AND %s < '%s'",
partitionColumn, datePartition, partitionColumn, nextPartition);
})
).orElse("");
return Lists.newArrayList(
String.format("SELECT * FROM %s%s%s", this.tableName(), where, limit));
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
private void calculateFirstBillingCycleDate() {
final int lastDayOfMonth = startDate.dayOfMonth().getMaximumValue();
final LocalDate billingCycleDate;
if (billingCycleDay > lastDayOfMonth) {
billingCycleDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), lastDayOfMonth, startDate.getChronology());
} else {
billingCycleDate = new LocalDate(startDate.getYear(), startDate.getMonthOfYear(), billingCycleDay, startDate.getChronology());
}
LocalDate proposedDate = billingCycleDate;
while (proposedDate.isBefore(startDate)) {
proposedDate = proposedDate.plus(billingPeriod.getPeriod());
}
firstBillingCycleDate = BillCycleDayCalculator.alignProposedBillCycleDate(proposedDate, billingCycleDay, billingPeriod);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testSinglePlan_ExactlyOnePeriodAfterStart() throws InvalidDateSequenceException {
final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
final LocalDate targetDate = startDate.plus(getBillingPeriod().getPeriod());
testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testSinglePlan_StartingMidFebruary() throws InvalidDateSequenceException {
final LocalDate startDate = invoiceUtil.buildDate(2011, 2, 15);
final LocalDate targetDate = startDate.plus(getBillingPeriod().getPeriod());
testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}
代码示例来源:origin: org.kill-bill.billing/killbill-invoice
@Test(groups = "fast")
public void testSinglePlan_StartingMidFebruaryOfLeapYear() throws InvalidDateSequenceException {
final LocalDate startDate = invoiceUtil.buildDate(2012, 2, 15);
final LocalDate targetDate = startDate.plus(getBillingPeriod().getPeriod());
testCalculateNumberOfBillingCycles(startDate, targetDate, 15, TWO);
}
代码示例来源:origin: com.ning.billing/killbill-overdue
@Override
public boolean evaluate(final BillingState state, final LocalDate date) {
LocalDate unpaidInvoiceTriggerDate = null;
if (timeSinceEarliestUnpaidInvoiceEqualsOrExceeds != null && state.getDateOfEarliestUnpaidInvoice() != null) { // no date => no unpaid invoices
unpaidInvoiceTriggerDate = state.getDateOfEarliestUnpaidInvoice().plus(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds.toJodaPeriod());
}
return
(numberOfUnpaidInvoicesEqualsOrExceeds == null || state.getNumberOfUnpaidInvoices() >= numberOfUnpaidInvoicesEqualsOrExceeds) &&
(totalUnpaidInvoiceBalanceEqualsOrExceeds == null || totalUnpaidInvoiceBalanceEqualsOrExceeds.compareTo(state.getBalanceOfUnpaidInvoices()) <= 0) &&
(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds == null ||
(unpaidInvoiceTriggerDate != null && !unpaidInvoiceTriggerDate.isAfter(date))) &&
(responseForLastFailedPayment == null || responseIsIn(state.getResponseForLastFailedPayment(), responseForLastFailedPayment)) &&
(controlTag == null || isTagIn(controlTag, state.getTags()));
}
代码示例来源:origin: org.kill-bill.billing/killbill-overdue
@Override
public boolean evaluate(final BillingState state, final LocalDate date) {
LocalDate unpaidInvoiceTriggerDate = null;
if (timeSinceEarliestUnpaidInvoiceEqualsOrExceeds != null && state.getDateOfEarliestUnpaidInvoice() != null) { // no date => no unpaid invoices
unpaidInvoiceTriggerDate = state.getDateOfEarliestUnpaidInvoice().plus(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds.toJodaPeriod());
}
return
(numberOfUnpaidInvoicesEqualsOrExceeds == null || state.getNumberOfUnpaidInvoices() >= numberOfUnpaidInvoicesEqualsOrExceeds) &&
(totalUnpaidInvoiceBalanceEqualsOrExceeds == null || totalUnpaidInvoiceBalanceEqualsOrExceeds.compareTo(state.getBalanceOfUnpaidInvoices()) <= 0) &&
(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds == null ||
(unpaidInvoiceTriggerDate != null && !unpaidInvoiceTriggerDate.isAfter(date))) &&
(responseForLastFailedPayment == null || responseIsIn(state.getResponseForLastFailedPayment(), responseForLastFailedPayment)) &&
(controlTagInclusion == null || isTagIn(controlTagInclusion, state.getTags())) &&
(controlTagExclusion == null || isTagNotIn(controlTagExclusion, state.getTags()));
}
代码示例来源:origin: com.ning.billing/killbill-analytics
public BusinessInvoiceItemModelDao(@Nullable final String externalKey, final InvoiceItem invoiceItem, @Nullable final Plan plan, @Nullable final PlanPhase planPhase) {
this(invoiceItem.getAmount(), planPhase != null ? planPhase.getBillingPeriod().toString() : null, invoiceItem.getCreatedDate(), invoiceItem.getCurrency(),
/* Populate end date for fixed items for convenience (null in invoice_items table) */
(invoiceItem.getEndDate() == null && planPhase != null) ? invoiceItem.getStartDate().plus(planPhase.getDuration().toJodaPeriod()) : invoiceItem.getEndDate(),
externalKey, invoiceItem.getInvoiceId(), invoiceItem.getId(), invoiceItem.getLinkedItemId(), invoiceItem.getInvoiceItemType().toString(),
planPhase != null ? planPhase.getPhaseType().toString() : null, plan != null ? plan.getProduct().getCategory().toString() : null,
plan != null ? plan.getProduct().getName() : null, plan != null ? plan.getProduct().getCatalogName() : null,
planPhase != null ? planPhase.getName() : null, invoiceItem.getStartDate(), invoiceItem.getUpdatedDate());
}
内容来源于网络,如有侵权,请联系作者删除!