本文整理了Java中java.time.YearMonth.plusMonths()
方法的一些代码示例,展示了YearMonth.plusMonths()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.plusMonths()
方法的具体详情如下:
包路径:java.time.YearMonth
类名称:YearMonth
方法名:plusMonths
[英]Returns a copy of this year-month with the specified period in months added.
This instance is immutable and unaffected by this method call.
[中]返回添加了指定期间(以月为单位)的本年月份的副本。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns a {@link java.time.YearMonth} that is {@code months} months after this year/month.
*
* @param self a YearMonth
* @param months the number of months to add
* @return a Year
* @since 2.5.0
*/
public static YearMonth plus(final YearMonth self, long months) {
return self.plusMonths(months);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a copy of this year-month with the specified period in months subtracted.
* <p>
* This instance is immutable and unaffected by this method call.
*
* @param monthsToSubtract the months to subtract, may be negative
* @return a {@code YearMonth} based on this year-month with the months subtracted, not null
* @throws DateTimeException if the result exceeds the supported range
*/
public YearMonth minusMonths(long monthsToSubtract) {
return (monthsToSubtract == Long.MIN_VALUE ? plusMonths(Long.MAX_VALUE).plusMonths(1) : plusMonths(-monthsToSubtract));
}
代码示例来源:origin: stackoverflow.com
YearMonth q2016_ymStart = YearMonth.of( 2016 , 1 ); // 2016-01
YearMonth q2016_ymStop = q2016_ymStart.plusMonths( 3 ); // 2016-04 for half-open quarter.
…
myPreparedStatement.setString( … , q2016_ymStart.toString() );
myPreparedStatement.setString( … , q2016_ymStop.toString() );
代码示例来源:origin: com.sqlapp/sqlapp-core
/**
* 月の加算を実行します
*
* @param date
* 日付型
* @param months
* 加算する月
* @return 月を加算した結果のカレンダー
*/
public static YearMonth addMonths(final YearMonth date, final int months) {
if (date == null) {
return null;
}
return date.plusMonths(months);
}
代码示例来源:origin: stackoverflow.com
// TODO: Which time zone are you interested in?
YearMonth yearMonth = YearMonth.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMM");
List<String> dates = new ArrayList<>();
for (int i = 0; i < 6; i++) {
dates.add(formatter.format(yearMonth.plusMonths(i)));
}
代码示例来源:origin: stackoverflow.com
YearMonth from = YearMonth.of(2010, 10);
YearMonth to = YearMonth.of(2011, 2);
List<YearMonth> list = new ArrayList<> ();
for (YearMonth ym = from; !ym.isAfter(to); ym = ym.plusMonths(1)) {
list.add(ym);
}
代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker
/**
* buttonNextMonthActionPerformed, This event is called when the next month button is pressed.
* This sets the YearMonth of the calendar to the next month, and redraws the calendar.
*/
private void buttonNextMonthActionPerformed(ActionEvent e) {
// We catch and ignore any exceptions at the minimum and maximum of the local date range.
try {
drawCalendar(displayedYearMonth.plusMonths(1));
} catch (Exception ex) {
}
}
代码示例来源:origin: stackoverflow.com
// TODO: Which time zone are you interested in?
YearMonth yearMonth = new YearMonth();
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMM");
List<String> dates = new ArrayList<>();
for (int i = 0; i < 6; i++) {
dates.add(formatter.print(yearMonth.plusMonths(i)));
}
代码示例来源:origin: stackoverflow.com
YearMonth start = YearMonth.of( 2008 , Month.OCTOBER );
YearMonth stop = YearMonth.of( 2009 , Month.DECEMBER );
List<YearMonth> yms = new ArrayList<>();
YearMonth ym = start ;
while( ! ym.isAfter( stop ) ) {
yms.add( ym );
// Set up the next loop.
ym = ym.plusMonths( 1 );
}
代码示例来源:origin: stackoverflow.com
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu.MM");
YearMonth date = YearMonth.parse("2010.01", formatter);
YearMonth end = YearMonth.parse("2010.05", formatter);
while (!date.isAfter(end)) {
System.out.println(date.format(formatter));
date = date.plusMonths(1);
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM-yyyy", Locale.ENGLISH);
YearMonth startDate = YearMonth.parse("Jan-2015", formatter);
YearMonth endDate = YearMonth.parse("Apr-2015", formatter);
while(startDate.isBefore(endDate)) {
System.out.println(startDate.format(formatter));
startDate = startDate.plusMonths(1);
}
}
代码示例来源:origin: stackoverflow.com
YearMonth ym = ymStart;
do {
int daysInMonth = ym.lengthOfMonth ();
String monthName = ym.getMonth ().getDisplayName ( TextStyle.FULL , Locale.CANADA_FRENCH );
System.out.println ( ym + " : " + daysInMonth + " jours en " + monthName );
// Prepare for next loop.
ym = ym.plusMonths ( 1 );
} while ( ym.isBefore ( ymStop ) );
代码示例来源:origin: br.com.jarch/jarch-utils
public static Collection<YearMonth> generateFromLocalDate(LocalDate start, LocalDate end) {
YearMonth yearMonthActual = YearMonth.of(start.getYear(), start.getMonth());
YearMonth yearMonthEnd = YearMonth.of(end.getYear(), end.getMonth());
List<YearMonth> listYearMonthReturn = new ArrayList<>();
do {
listYearMonthReturn.add(yearMonthActual);
yearMonthActual = yearMonthActual.plusMonths(1);
} while (yearMonthActual.isBefore(yearMonthEnd));
listYearMonthReturn.add(yearMonthEnd);
return listYearMonthReturn;
}
}
代码示例来源:origin: br.com.jarch/jarch-util
public static Collection<YearMonth> generateFromLocalDate(LocalDate start, LocalDate end) {
YearMonth yearMonthActual = YearMonth.of(start.getYear(), start.getMonth());
YearMonth yearMonthEnd = YearMonth.of(end.getYear(), end.getMonth());
List<YearMonth> listYearMonthReturn = new ArrayList<>();
do {
listYearMonthReturn.add(yearMonthActual);
yearMonthActual = yearMonthActual.plusMonths(1);
} while (yearMonthActual.isBefore(yearMonthEnd));
listYearMonthReturn.add(yearMonthEnd);
return listYearMonthReturn;
}
}
代码示例来源:origin: OpenGamma/Strata
public void test_valuePointSensitivity_forward() {
YearMonth month = VAL_MONTH.plusMonths(3);
SimplePriceIndexValues test = SimplePriceIndexValues.of(US_CPI_U, VAL_DATE, CURVE_NOFIX, USCPI_TS);
PriceIndexObservation obs = PriceIndexObservation.of(US_CPI_U, month);
InflationRateSensitivity expected = InflationRateSensitivity.of(obs, 1d);
assertEquals(test.valuePointSensitivity(obs), expected);
}
代码示例来源:origin: OpenGamma/Strata
public void test_parameterSensitivity() {
SimplePriceIndexValues test = SimplePriceIndexValues.of(US_CPI_U, VAL_DATE, CURVE_NOFIX, USCPI_TS);
InflationRateSensitivity point =
InflationRateSensitivity.of(PriceIndexObservation.of(US_CPI_U, VAL_MONTH.plusMonths(3)), 1d);
assertEquals(test.parameterSensitivity(point).size(), 1);
}
代码示例来源:origin: OpenGamma/Strata
public void coverage() {
AbsoluteIborFutureTemplate test = AbsoluteIborFutureTemplate.of(YEAR_MONTH, CONVENTION);
coverImmutableBean(test);
AbsoluteIborFutureTemplate test2 = AbsoluteIborFutureTemplate.of(YEAR_MONTH.plusMonths(1), CONVENTION2);
coverBeanEquals(test, test2);
}
代码示例来源:origin: OpenGamma/Strata
public void coverage() {
PriceIndexObservation test = PriceIndexObservation.of(GB_HICP, FIXING_MONTH);
coverImmutableBean(test);
PriceIndexObservation test2 = PriceIndexObservation.of(CH_CPI, FIXING_MONTH.plusMonths(1));
coverBeanEquals(test, test2);
}
代码示例来源:origin: OpenGamma/Strata
public void test_parameterSensitivity() {
HistoricPriceIndexValues test = HistoricPriceIndexValues.of(US_CPI_U, VAL_DATE, USCPI_TS);
InflationRateSensitivity point =
InflationRateSensitivity.of(PriceIndexObservation.of(US_CPI_U, VAL_MONTH.plusMonths(3)), 1d);
assertThrows(MarketDataNotFoundException.class, () -> test.parameterSensitivity(point));
}
代码示例来源:origin: OpenGamma/Strata
public void test_valuePointSensitivity_forward() {
YearMonth month = VAL_MONTH.plusMonths(3);
HistoricPriceIndexValues test = HistoricPriceIndexValues.of(US_CPI_U, VAL_DATE, USCPI_TS);
PriceIndexObservation obs = PriceIndexObservation.of(US_CPI_U, month);
assertThrows(MarketDataNotFoundException.class, () -> test.value(obs));
assertThrows(MarketDataNotFoundException.class, () -> test.valuePointSensitivity(obs));
}
内容来源于网络,如有侵权,请联系作者删除!