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

x33g5p2x  于2022-02-05 转载在 其他  
字(13.3k)|赞(0)|评价(0)|浏览(152)

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

YearMonth.withFieldAdded介绍

[英]Returns a copy of this year-month with the value of the specified field increased.

If the addition is zero, then this is returned.

These three lines are equivalent:

  1. YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6);
  2. YearMonth added = ym.plusMonths(6);
  3. YearMonth added = ym.monthOfYear().addToCopy(6);

[中]返回指定字段值增加的本年月份的副本。
如果加法为零,则返回this
这三条线是等效的:

  1. YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6);
  2. YearMonth added = ym.plusMonths(6);
  3. YearMonth added = ym.monthOfYear().addToCopy(6);

代码示例

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Returns a copy of this year-month plus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusMonths(6);
  9. * YearMonth added = ym.plus(Period.months(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to add, may be negative
  14. * @return the new year-month plus the increased months, never null
  15. */
  16. public YearMonth plusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), months);
  18. }

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Returns a copy of this year-month plus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusYears(6);
  9. * YearMonth added = ym.plus(Period.years(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.years(), 6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to add, may be negative
  14. * @return the new year-month plus the increased years, never null
  15. */
  16. public YearMonth plusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), years);
  18. }

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Returns a copy of this year-month plus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusYears(6);
  9. * YearMonth added = ym.plus(Period.years(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.years(), 6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to add, may be negative
  14. * @return the new year-month plus the increased years, never null
  15. */
  16. public YearMonth plusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), years);
  18. }

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Returns a copy of this year-month plus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusMonths(6);
  9. * YearMonth added = ym.plus(Period.months(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to add, may be negative
  14. * @return the new year-month plus the increased months, never null
  15. */
  16. public YearMonth plusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), months);
  18. }

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Returns a copy of this year-month minus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusMonths(6);
  9. * YearMonth subtracted = ym.minus(Period.months(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to subtract, may be negative
  14. * @return the new year-month minus the increased months, never null
  15. */
  16. public YearMonth minusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
  18. }

代码示例来源:origin: joda-time/joda-time

  1. /**
  2. * Returns a copy of this year-month minus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusYears(6);
  9. * YearMonth subtracted = ym.minus(Period.years(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.years(), -6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to subtract, may be negative
  14. * @return the new year-month minus the increased years, never null
  15. */
  16. public YearMonth minusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), FieldUtils.safeNegate(years));
  18. }

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Returns a copy of this year-month minus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusYears(6);
  9. * YearMonth subtracted = ym.minus(Period.years(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.years(), -6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to subtract, may be negative
  14. * @return the new year-month minus the increased years, never null
  15. */
  16. public YearMonth minusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), FieldUtils.safeNegate(years));
  18. }

代码示例来源:origin: JodaOrg/joda-time

  1. /**
  2. * Returns a copy of this year-month minus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusMonths(6);
  9. * YearMonth subtracted = ym.minus(Period.months(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to subtract, may be negative
  14. * @return the new year-month minus the increased months, never null
  15. */
  16. public YearMonth minusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
  18. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Returns a copy of this year-month plus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusMonths(6);
  9. * YearMonth added = ym.plus(Period.months(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to add, may be negative
  14. * @return the new year-month plus the increased months, never null
  15. */
  16. public YearMonth plusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), months);
  18. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Returns a copy of this year-month plus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusYears(6);
  9. * YearMonth added = ym.plus(Period.years(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.years(), 6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to add, may be negative
  14. * @return the new year-month plus the increased years, never null
  15. */
  16. public YearMonth plusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), years);
  18. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Returns a copy of this year-month minus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusYears(6);
  9. * YearMonth subtracted = ym.minus(Period.years(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.years(), -6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to subtract, may be negative
  14. * @return the new year-month minus the increased years, never null
  15. */
  16. public YearMonth minusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), FieldUtils.safeNegate(years));
  18. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Returns a copy of this year-month minus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusMonths(6);
  9. * YearMonth subtracted = ym.minus(Period.months(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to subtract, may be negative
  14. * @return the new year-month minus the increased months, never null
  15. */
  16. public YearMonth minusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
  18. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

  1. /**
  2. * Returns a copy of this year-month plus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusYears(6);
  9. * YearMonth added = ym.plus(Period.years(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.years(), 6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to add, may be negative
  14. * @return the new year-month plus the increased years, never null
  15. */
  16. public YearMonth plusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), years);
  18. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Returns a copy of this year-month plus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusMonths(6);
  9. * YearMonth added = ym.plus(Period.months(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to add, may be negative
  14. * @return the new year-month plus the increased months, never null
  15. */
  16. public YearMonth plusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), months);
  18. }

代码示例来源:origin: Nextdoor/bender

  1. /**
  2. * Returns a copy of this year-month plus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth added = ym.plusMonths(6);
  9. * YearMonth added = ym.plus(Period.months(6));
  10. * YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to add, may be negative
  14. * @return the new year-month plus the increased months, never null
  15. */
  16. public YearMonth plusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), months);
  18. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

  1. /**
  2. * Returns a copy of this year-month minus the specified number of years.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusYears(6);
  9. * YearMonth subtracted = ym.minus(Period.years(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.years(), -6);
  11. * </pre>
  12. *
  13. * @param years the amount of years to subtract, may be negative
  14. * @return the new year-month minus the increased years, never null
  15. */
  16. public YearMonth minusYears(int years) {
  17. return withFieldAdded(DurationFieldType.years(), FieldUtils.safeNegate(years));
  18. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

  1. /**
  2. * Returns a copy of this year-month minus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusMonths(6);
  9. * YearMonth subtracted = ym.minus(Period.months(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to subtract, may be negative
  14. * @return the new year-month minus the increased months, never null
  15. */
  16. public YearMonth minusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
  18. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Returns a copy of this year-month minus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusMonths(6);
  9. * YearMonth subtracted = ym.minus(Period.months(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to subtract, may be negative
  14. * @return the new year-month minus the increased months, never null
  15. */
  16. public YearMonth minusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
  18. }

代码示例来源:origin: redfish64/TinyTravelTracker

  1. /**
  2. * Returns a copy of this year-month minus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusMonths(6);
  9. * YearMonth subtracted = ym.minus(Period.months(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to subtract, may be negative
  14. * @return the new year-month minus the increased months, never null
  15. */
  16. public YearMonth minusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
  18. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Returns a copy of this year-month minus the specified number of months.
  3. * <p>
  4. * This year-month instance is immutable and unaffected by this method call.
  5. * <p>
  6. * The following three lines are identical in effect:
  7. * <pre>
  8. * YearMonth subtracted = ym.minusMonths(6);
  9. * YearMonth subtracted = ym.minus(Period.months(6));
  10. * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6);
  11. * </pre>
  12. *
  13. * @param months the amount of months to subtract, may be negative
  14. * @return the new year-month minus the increased months, never null
  15. */
  16. public YearMonth minusMonths(int months) {
  17. return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months));
  18. }

相关文章