本文整理了Java中java.time.Period.plus()
方法的一些代码示例,展示了Period.plus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Period.plus()
方法的具体详情如下:
包路径:java.time.Period
类名称:Period
方法名:plus
[英]Returns a copy of this period with the specified amount added.
This input amount is converted to a Period using from(TemporalAmount). This operates separately on the years, months and days.
For example, "1 year, 6 months and 3 days" plus "2 years, 2 months and 2 days" returns "3 years, 8 months and 5 days".
This instance is immutable and unaffected by this method call.
[中]返回添加了指定金额的此期间的副本。
此输入量使用from(临时计数)转换为期间。这在年、月和日分别运行。
例如,“1年、6个月和3天”加上“2年、2个月和2天”返回“3年、8个月和5天”。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: goldmansachs/jdmn
private TemporalAmount plus(TemporalAmount first, TemporalAmount second) {
if (first instanceof Period && second instanceof Period) {
return ((Period) first).plus(second);
} else if (first instanceof Duration && second instanceof Duration) {
return ((Duration)first).plus((Duration)second);
} else {
throw new DMNRuntimeException(String.format("Cannot add '%s' and '%s'", first, second));
}
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
private TemporalAmount plus(TemporalAmount first, TemporalAmount second) {
if (first instanceof Period && second instanceof Period) {
return ((Period) first).plus(second);
} else if (first instanceof Duration && second instanceof Duration) {
return ((Duration)first).plus((Duration)second);
} else {
throw new DMNRuntimeException(String.format("Cannot add '%s' and '%s'", first, second));
}
}
代码示例来源:origin: com.enonic.xp/core-api
period = period.plus( Period.parse( "P" + operatorString + valueString + unitTypeString.substring( 0, 1 ) ) );
代码示例来源:origin: OpenGamma/Strata
@Override
public double approximateMaturity(LocalDate valuationDate) {
return minimumPeriod.plus(convention.getIndex().getTenor()).toTotalMonths() / 12d;
}
代码示例来源:origin: OpenGamma/Strata
@ImmutablePreBuild
private static void preBuild(Builder builder) {
if (builder.periodToEnd == null && builder.convention != null && builder.periodToStart != null) {
builder.periodToEnd = builder.periodToStart.plus(builder.convention.getIndex().getTenor().getPeriod());
}
}
代码示例来源:origin: org.threeten/threeten-extra
/**
* Returns a copy of this amount with the specified amount added.
* <p>
* The parameter is converted using {@link PeriodDuration#from(TemporalAmount)}.
* The period and duration are combined separately.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param amountToAdd the amount to add, not null
* @return a {@code Days} based on this instance with the requested amount added, not null
* @throws DateTimeException if the specified amount contains an invalid unit
* @throws ArithmeticException if numeric overflow occurs
*/
public PeriodDuration plus(TemporalAmount amountToAdd) {
PeriodDuration other = PeriodDuration.from(amountToAdd);
return of(period.plus(other.period), duration.plus(other.duration));
}
代码示例来源:origin: OpenGamma/Strata
ReferenceData refData) {
Period periodToEnd = periodToStart.plus(getIndex().getTenor());
return createTrade(tradeDate, periodToStart, periodToEnd, buySell, notional, fixedRate, refData);
代码示例来源:origin: OpenGamma/Strata
/**
* Obtains a template based on the specified period and index.
* <p>
* The period from the spot date to the start date is specified.
* The period from the spot date to the end date will be the period to start
* plus the tenor of the index.
* <p>
* For example, a '2 x 5' FRA has a period to the start date of 2 months.
* The index will be a 3 month index, such as 'USD-LIBOR-3M'.
* The period to the end date will be the period to the start date plus the index tenor.
*
* @param periodToStart the period between the spot date and the start date
* @param index the index that defines the market convention
* @return the template
*/
public static FraTemplate of(Period periodToStart, IborIndex index) {
return of(periodToStart, periodToStart.plus(index.getTenor().getPeriod()), FraConvention.of(index));
}
代码示例来源:origin: OpenGamma/Strata
@Override
public double initialGuess(MarketData marketData, ValueType valueType) {
if (ValueType.ZERO_RATE.equals(valueType) || ValueType.FORWARD_RATE.equals(valueType)) {
return marketData.getValue(rateId);
}
if (ValueType.DISCOUNT_FACTOR.equals(valueType)) {
double approximateMaturity = template.getPeriodToStart().plus(template.getTenor()).toTotalMonths() / 12.0d;
return Math.exp(-approximateMaturity * marketData.getValue(rateId));
}
return 0d;
}
代码示例来源:origin: OpenGamma/Strata
@Override
public double initialGuess(MarketData marketData, ValueType valueType) {
if (ValueType.ZERO_RATE.equals(valueType) || ValueType.FORWARD_RATE.equals(valueType)) {
return marketData.getValue(rateId);
}
if (ValueType.DISCOUNT_FACTOR.equals(valueType)) {
double approximateMaturity = template.getPeriodToStart().plus(template.getTenor()).toTotalMonths() / 12.0d;
return Math.exp(-approximateMaturity * marketData.getValue(rateId));
}
return 0d;
}
代码示例来源:origin: OpenGamma/Strata
@Override
public double initialGuess(MarketData marketData, ValueType valueType) {
if (ValueType.ZERO_RATE.equals(valueType) || ValueType.FORWARD_RATE.equals(valueType)) {
return marketData.getValue(rateId);
}
if (ValueType.DISCOUNT_FACTOR.equals(valueType)) {
double approximateMaturity = template.getPeriodToStart().plus(template.getTenor()).toTotalMonths() / 12.0d;
return Math.exp(-approximateMaturity * marketData.getValue(rateId));
}
return 0d;
}
代码示例来源:origin: OpenGamma/Strata
public static DummyFraCurveNode of(Period periodToStart, IborIndex index, ObservableId rateId, CurveNodeDateOrder order) {
return new DummyFraCurveNode(
periodToStart,
periodToStart.plus(index.getTenor().getPeriod()),
rateId,
0,
"Dummy:" + periodToStart,
order);
}
代码示例来源:origin: OpenGamma/Strata
public static DummyFraCurveNode of(Period periodToStart, IborIndex index, ObservableId rateId) {
return new DummyFraCurveNode(
periodToStart,
periodToStart.plus(index.getTenor().getPeriod()),
rateId,
0,
"Dummy:" + periodToStart,
CurveNodeDateOrder.DEFAULT);
}
代码示例来源:origin: OpenGamma/Strata
public static DummyFraCurveNode of(Period periodToStart, IborIndex index, ObservableId rateId, double spread) {
return new DummyFraCurveNode(
periodToStart,
periodToStart.plus(index.getTenor().getPeriod()),
rateId,
spread,
"Dummy:" + periodToStart,
CurveNodeDateOrder.DEFAULT);
}
代码示例来源:origin: org.kie/kie-dmn-feel
return ((String) left) + ((String) right);
} else if ( left instanceof Period && right instanceof Period ) {
return ((Period) left).plus( (Period) right);
} else if ( left instanceof Duration && right instanceof Duration ) {
return ((Duration) left).plus( (Duration) right);
内容来源于网络,如有侵权,请联系作者删除!