org.joda.time.LocalDateTime.plusYears()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中org.joda.time.LocalDateTime.plusYears()方法的一些代码示例,展示了LocalDateTime.plusYears()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.plusYears()方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:plusYears

LocalDateTime.plusYears介绍

[英]Returns a copy of this datetime plus the specified number of years.

This LocalDateTime instance is immutable and unaffected by this method call.

The following three lines are identical in effect:

LocalDateTime added = dt.plusYears(6); 
LocalDateTime added = dt.plus(Period.years(6)); 
LocalDateTime added = dt.withFieldAdded(DurationFieldType.years(), 6);

[中]返回此datetime加上指定年数的副本。
此LocalDateTime实例是不可变的,不受此方法调用的影响。
以下三行实际上是相同的:

LocalDateTime added = dt.plusYears(6); 
LocalDateTime added = dt.plus(Period.years(6)); 
LocalDateTime added = dt.withFieldAdded(DurationFieldType.years(), 6);

代码示例

代码示例来源:origin: com.synaptix/SynaptixWidget

break;
case 'y':
  dateTime = dateTime.plusYears(nb);
  break;
case 'H':

代码示例来源:origin: effektif/effektif

@Test
public void testIn4Years() {
 LocalDateTime base = new LocalDateTime(2015, 12, 28, 9, 0, 0, 0);
 LocalDateTime absoluteTime = RelativeTime.years(4).resolve(base);
 assertEquals(endOfDay(base.plusYears(4)), absoluteTime);
}

代码示例来源:origin: dremio/dremio-oss

@Test
public void runTest() throws Exception {
 LocalDateTime dt = new LocalDateTime(System.currentTimeMillis());
 String value1 = formatter.print(dt);
 logger.info(value1);
 dt = dt.plusYears(1);
 String value2 = formatter.print(dt);
 logger.info(value2);
 ElasticsearchCluster.ColumnData[] data = new ElasticsearchCluster.ColumnData[]{
     new ElasticsearchCluster.ColumnData("field", DATE, ImmutableMap.of("format", format), new Object[][]{
         {value1},
         {value2}
     })
 };
 elastic.load(schema, table, data);
 String sql = "select field from elasticsearch." + schema + "." + table;
 testBuilder()
     .sqlQuery(sql)
     .ordered()
     .baselineColumns("field")
     .baselineValues(formatter.parse(value1))
     .baselineValues(formatter.parse(value2))
     .go();
}

代码示例来源:origin: dremio/dremio-oss

int year = roundedUp.getYear();
int roundedUpYear = 10 - year % 10;
return roundedUp.plusYears(roundedUpYear);
int year = roundedUp.getYear();
int roundedUpYear = 100 - year % 100;
return roundedUp.plusYears(roundedUpYear);
int year = roundedUp.getYear();
int roundedUpYear = 1000 - year % 1000;
return roundedUp.plusYears(roundedUpYear);

相关文章