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

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

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

YearMonthDay.getValues介绍

暂无

代码示例

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

  1. /**
  2. * Sets this field in a copy of the YearMonthDay.
  3. * <p>
  4. * The YearMonthDay attached to this property is unchanged by this call.
  5. * Instead, a new instance is returned.
  6. *
  7. * @param value the value to set the field in the copy to
  8. * @return a copy of the YearMonthDay with the field value changed
  9. * @throws IllegalArgumentException if the value isn't valid
  10. */
  11. public YearMonthDay setCopy(int value) {
  12. int[] newValues = iYearMonthDay.getValues();
  13. newValues = getField().set(iYearMonthDay, iFieldIndex, newValues, value);
  14. return new YearMonthDay(iYearMonthDay, newValues);
  15. }

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

  1. /**
  2. * Sets this field in a copy of the YearMonthDay.
  3. * <p>
  4. * The YearMonthDay attached to this property is unchanged by this call.
  5. * Instead, a new instance is returned.
  6. *
  7. * @param value the value to set the field in the copy to
  8. * @return a copy of the YearMonthDay with the field value changed
  9. * @throws IllegalArgumentException if the value isn't valid
  10. */
  11. public YearMonthDay setCopy(int value) {
  12. int[] newValues = iYearMonthDay.getValues();
  13. newValues = getField().set(iYearMonthDay, iFieldIndex, newValues, value);
  14. return new YearMonthDay(iYearMonthDay, newValues);
  15. }

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

  1. /**
  2. * Sets this field in a copy of the YearMonthDay to a parsed text value.
  3. * <p>
  4. * The YearMonthDay attached to this property is unchanged by this call.
  5. * Instead, a new instance is returned.
  6. *
  7. * @param text the text value to set
  8. * @param locale optional locale to use for selecting a text symbol
  9. * @return a copy of the YearMonthDay with the field value changed
  10. * @throws IllegalArgumentException if the text value isn't valid
  11. */
  12. public YearMonthDay setCopy(String text, Locale locale) {
  13. int[] newValues = iYearMonthDay.getValues();
  14. newValues = getField().set(iYearMonthDay, iFieldIndex, newValues, text, locale);
  15. return new YearMonthDay(iYearMonthDay, newValues);
  16. }

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

  1. /**
  2. * Sets this field in a copy of the YearMonthDay to a parsed text value.
  3. * <p>
  4. * The YearMonthDay attached to this property is unchanged by this call.
  5. * Instead, a new instance is returned.
  6. *
  7. * @param text the text value to set
  8. * @param locale optional locale to use for selecting a text symbol
  9. * @return a copy of the YearMonthDay with the field value changed
  10. * @throws IllegalArgumentException if the text value isn't valid
  11. */
  12. public YearMonthDay setCopy(String text, Locale locale) {
  13. int[] newValues = iYearMonthDay.getValues();
  14. newValues = getField().set(iYearMonthDay, iFieldIndex, newValues, text, locale);
  15. return new YearMonthDay(iYearMonthDay, newValues);
  16. }

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

  1. /**
  2. * Adds to the value of this field in a copy of this YearMonthDay.
  3. * <p>
  4. * The value will be added to this field. If the value is too large to be
  5. * added solely to this field then it will affect larger fields.
  6. * Smaller fields are unaffected.
  7. * <p>
  8. * If the result would be too large, beyond the maximum year, then an
  9. * IllegalArgumentException is thrown.
  10. * <p>
  11. * The YearMonthDay attached to this property is unchanged by this call.
  12. * Instead, a new instance is returned.
  13. *
  14. * @param valueToAdd the value to add to the field in the copy
  15. * @return a copy of the YearMonthDay with the field value changed
  16. * @throws IllegalArgumentException if the value isn't valid
  17. */
  18. public YearMonthDay addToCopy(int valueToAdd) {
  19. int[] newValues = iYearMonthDay.getValues();
  20. newValues = getField().add(iYearMonthDay, iFieldIndex, newValues, valueToAdd);
  21. return new YearMonthDay(iYearMonthDay, newValues);
  22. }

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

  1. /**
  2. * Adds to the value of this field in a copy of this YearMonthDay wrapping
  3. * within this field if the maximum value is reached.
  4. * <p>
  5. * The value will be added to this field. If the value is too large to be
  6. * added solely to this field then it wraps within this field.
  7. * Other fields are unaffected.
  8. * <p>
  9. * For example,
  10. * <code>2004-12-20</code> addWrapField one month returns <code>2004-01-20</code>.
  11. * <p>
  12. * The YearMonthDay attached to this property is unchanged by this call.
  13. * Instead, a new instance is returned.
  14. *
  15. * @param valueToAdd the value to add to the field in the copy
  16. * @return a copy of the YearMonthDay with the field value changed
  17. * @throws IllegalArgumentException if the value isn't valid
  18. */
  19. public YearMonthDay addWrapFieldToCopy(int valueToAdd) {
  20. int[] newValues = iYearMonthDay.getValues();
  21. newValues = getField().addWrapField(iYearMonthDay, iFieldIndex, newValues, valueToAdd);
  22. return new YearMonthDay(iYearMonthDay, newValues);
  23. }

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

  1. /**
  2. * Adds to the value of this field in a copy of this YearMonthDay.
  3. * <p>
  4. * The value will be added to this field. If the value is too large to be
  5. * added solely to this field then it will affect larger fields.
  6. * Smaller fields are unaffected.
  7. * <p>
  8. * If the result would be too large, beyond the maximum year, then an
  9. * IllegalArgumentException is thrown.
  10. * <p>
  11. * The YearMonthDay attached to this property is unchanged by this call.
  12. * Instead, a new instance is returned.
  13. *
  14. * @param valueToAdd the value to add to the field in the copy
  15. * @return a copy of the YearMonthDay with the field value changed
  16. * @throws IllegalArgumentException if the value isn't valid
  17. */
  18. public YearMonthDay addToCopy(int valueToAdd) {
  19. int[] newValues = iYearMonthDay.getValues();
  20. newValues = getField().add(iYearMonthDay, iFieldIndex, newValues, valueToAdd);
  21. return new YearMonthDay(iYearMonthDay, newValues);
  22. }

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

  1. /**
  2. * Returns a copy of this date with the year field updated.
  3. * <p>
  4. * YearMonthDay is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * year changed.
  7. *
  8. * @param year the year to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. * @since 1.3
  12. */
  13. public YearMonthDay withYear(int year) {
  14. int[] newValues = getValues();
  15. newValues = getChronology().year().set(this, YEAR, newValues, year);
  16. return new YearMonthDay(this, newValues);
  17. }

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

  1. /**
  2. * Adds to the value of this field in a copy of this YearMonthDay wrapping
  3. * within this field if the maximum value is reached.
  4. * <p>
  5. * The value will be added to this field. If the value is too large to be
  6. * added solely to this field then it wraps within this field.
  7. * Other fields are unaffected.
  8. * <p>
  9. * For example,
  10. * <code>2004-12-20</code> addWrapField one month returns <code>2004-01-20</code>.
  11. * <p>
  12. * The YearMonthDay attached to this property is unchanged by this call.
  13. * Instead, a new instance is returned.
  14. *
  15. * @param valueToAdd the value to add to the field in the copy
  16. * @return a copy of the YearMonthDay with the field value changed
  17. * @throws IllegalArgumentException if the value isn't valid
  18. */
  19. public YearMonthDay addWrapFieldToCopy(int valueToAdd) {
  20. int[] newValues = iYearMonthDay.getValues();
  21. newValues = getField().addWrapField(iYearMonthDay, iFieldIndex, newValues, valueToAdd);
  22. return new YearMonthDay(iYearMonthDay, newValues);
  23. }

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

  1. /**
  2. * Returns a copy of this date with the day of month field updated.
  3. * <p>
  4. * YearMonthDay is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * day of month changed.
  7. *
  8. * @param dayOfMonth the day of month to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. * @since 1.3
  12. */
  13. public YearMonthDay withDayOfMonth(int dayOfMonth) {
  14. int[] newValues = getValues();
  15. newValues = getChronology().dayOfMonth().set(this, DAY_OF_MONTH, newValues, dayOfMonth);
  16. return new YearMonthDay(this, newValues);
  17. }

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

  1. /**
  2. * Returns a copy of this date with the month of year field updated.
  3. * <p>
  4. * YearMonthDay is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * month of year changed.
  7. *
  8. * @param monthOfYear the month of year to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. * @since 1.3
  12. */
  13. public YearMonthDay withMonthOfYear(int monthOfYear) {
  14. int[] newValues = getValues();
  15. newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear);
  16. return new YearMonthDay(this, newValues);
  17. }

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

  1. /**
  2. * Returns a copy of this date with the year field updated.
  3. * <p>
  4. * YearMonthDay is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * year changed.
  7. *
  8. * @param year the year to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. * @since 1.3
  12. */
  13. public YearMonthDay withYear(int year) {
  14. int[] newValues = getValues();
  15. newValues = getChronology().year().set(this, YEAR, newValues, year);
  16. return new YearMonthDay(this, newValues);
  17. }

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

  1. /**
  2. * Returns a copy of this date with the month of year field updated.
  3. * <p>
  4. * YearMonthDay is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * month of year changed.
  7. *
  8. * @param monthOfYear the month of year to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. * @since 1.3
  12. */
  13. public YearMonthDay withMonthOfYear(int monthOfYear) {
  14. int[] newValues = getValues();
  15. newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear);
  16. return new YearMonthDay(this, newValues);
  17. }

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

  1. /**
  2. * Returns a copy of this date with the day of month field updated.
  3. * <p>
  4. * YearMonthDay is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * day of month changed.
  7. *
  8. * @param dayOfMonth the day of month to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. * @since 1.3
  12. */
  13. public YearMonthDay withDayOfMonth(int dayOfMonth) {
  14. int[] newValues = getValues();
  15. newValues = getChronology().dayOfMonth().set(this, DAY_OF_MONTH, newValues, dayOfMonth);
  16. return new YearMonthDay(this, newValues);
  17. }

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

  1. /**
  2. * Returns a copy of this date with the value of the specified field increased.
  3. * <p>
  4. * If the addition is zero, then <code>this</code> is returned.
  5. * <p>
  6. * These three lines are equivalent:
  7. * <pre>
  8. * YearMonthDay added = ymd.withFieldAdded(DurationFieldType.days(), 6);
  9. * YearMonthDay added = ymd.plusDays(6);
  10. * YearMonthDay added = ymd.dayOfMonth().addToCopy(6);
  11. * </pre>
  12. *
  13. * @param fieldType the field type to add to, not null
  14. * @param amount the amount to add
  15. * @return a copy of this instance with the field updated
  16. * @throws IllegalArgumentException if the value is null or invalid
  17. * @throws ArithmeticException if the new datetime exceeds the capacity
  18. */
  19. public YearMonthDay withFieldAdded(DurationFieldType fieldType, int amount) {
  20. int index = indexOfSupported(fieldType);
  21. if (amount == 0) {
  22. return this;
  23. }
  24. int[] newValues = getValues();
  25. newValues = getField(index).add(this, index, newValues, amount);
  26. return new YearMonthDay(this, newValues);
  27. }

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

  1. /**
  2. * Returns a copy of this date with the specified chronology.
  3. * This instance is immutable and unaffected by this method call.
  4. * <p>
  5. * This method retains the values of the fields, thus the result will
  6. * typically refer to a different instant.
  7. * <p>
  8. * The time zone of the specified chronology is ignored, as YearMonthDay
  9. * operates without a time zone.
  10. *
  11. * @param newChronology the new chronology, null means ISO
  12. * @return a copy of this datetime with a different chronology
  13. * @throws IllegalArgumentException if the values are invalid for the new chronology
  14. */
  15. public YearMonthDay withChronologyRetainFields(Chronology newChronology) {
  16. newChronology = DateTimeUtils.getChronology(newChronology);
  17. newChronology = newChronology.withUTC();
  18. if (newChronology == getChronology()) {
  19. return this;
  20. } else {
  21. YearMonthDay newYearMonthDay = new YearMonthDay(this, newChronology);
  22. newChronology.validate(newYearMonthDay, getValues());
  23. return newYearMonthDay;
  24. }
  25. }

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

  1. /**
  2. * Returns a copy of this date with the specified field set to a new value.
  3. * <p>
  4. * For example, if the field type is <code>dayOfMonth</code> then the day
  5. * would be changed in the returned instance.
  6. * <p>
  7. * These three lines are equivalent:
  8. * <pre>
  9. * YearMonthDay updated = ymd.withField(DateTimeFieldType.dayOfMonth(), 6);
  10. * YearMonthDay updated = ymd.dayOfMonth().setCopy(6);
  11. * YearMonthDay updated = ymd.property(DateTimeFieldType.dayOfMonth()).setCopy(6);
  12. * </pre>
  13. *
  14. * @param fieldType the field type to set, not null
  15. * @param value the value to set
  16. * @return a copy of this instance with the field set
  17. * @throws IllegalArgumentException if the value is null or invalid
  18. */
  19. public YearMonthDay withField(DateTimeFieldType fieldType, int value) {
  20. int index = indexOfSupported(fieldType);
  21. if (value == getValue(index)) {
  22. return this;
  23. }
  24. int[] newValues = getValues();
  25. newValues = getField(index).set(this, index, newValues, value);
  26. return new YearMonthDay(this, newValues);
  27. }

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

  1. /**
  2. * Returns a copy of this date with the specified field set to a new value.
  3. * <p>
  4. * For example, if the field type is <code>dayOfMonth</code> then the day
  5. * would be changed in the returned instance.
  6. * <p>
  7. * These three lines are equivalent:
  8. * <pre>
  9. * YearMonthDay updated = ymd.withField(DateTimeFieldType.dayOfMonth(), 6);
  10. * YearMonthDay updated = ymd.dayOfMonth().setCopy(6);
  11. * YearMonthDay updated = ymd.property(DateTimeFieldType.dayOfMonth()).setCopy(6);
  12. * </pre>
  13. *
  14. * @param fieldType the field type to set, not null
  15. * @param value the value to set
  16. * @return a copy of this instance with the field set
  17. * @throws IllegalArgumentException if the value is null or invalid
  18. */
  19. public YearMonthDay withField(DateTimeFieldType fieldType, int value) {
  20. int index = indexOfSupported(fieldType);
  21. if (value == getValue(index)) {
  22. return this;
  23. }
  24. int[] newValues = getValues();
  25. newValues = getField(index).set(this, index, newValues, value);
  26. return new YearMonthDay(this, newValues);
  27. }

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

  1. /**
  2. * Returns a copy of this date with the specified chronology.
  3. * This instance is immutable and unaffected by this method call.
  4. * <p>
  5. * This method retains the values of the fields, thus the result will
  6. * typically refer to a different instant.
  7. * <p>
  8. * The time zone of the specified chronology is ignored, as YearMonthDay
  9. * operates without a time zone.
  10. *
  11. * @param newChronology the new chronology, null means ISO
  12. * @return a copy of this datetime with a different chronology
  13. * @throws IllegalArgumentException if the values are invalid for the new chronology
  14. */
  15. public YearMonthDay withChronologyRetainFields(Chronology newChronology) {
  16. newChronology = DateTimeUtils.getChronology(newChronology);
  17. newChronology = newChronology.withUTC();
  18. if (newChronology == getChronology()) {
  19. return this;
  20. } else {
  21. YearMonthDay newYearMonthDay = new YearMonthDay(this, newChronology);
  22. newChronology.validate(newYearMonthDay, getValues());
  23. return newYearMonthDay;
  24. }
  25. }

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

  1. return this;
  2. int[] newValues = getValues();
  3. for (int i = 0; i < period.size(); i++) {
  4. DurationFieldType fieldType = period.getFieldType(i);

相关文章