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

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

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

LocalTime.withLocalMillis介绍

[英]Returns a copy of this time with different local millis.

The returned object will be a new instance of the same type. Only the millis will change, the chronology is kept. The returned object will be either be a new instance or this.
[中]返回具有不同本地毫秒数的此时间的副本。
返回的对象将是相同类型的新实例。只有米利会改变,年表会保留下来。返回的对象将是新实例或this

代码示例

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

  1. /**
  2. * Rounds to the nearest whole unit of this field on a copy of this
  3. * LocalTime, favoring the floor if halfway.
  4. *
  5. * @return a copy of the LocalTime with the field value changed
  6. */
  7. public LocalTime roundHalfFloorCopy() {
  8. return iInstant.withLocalMillis(iField.roundHalfFloor(iInstant.getLocalMillis()));
  9. }

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

  1. /**
  2. * Returns a copy of this time with the partial set of fields replacing
  3. * those from this instance.
  4. * <p>
  5. * For example, if the partial contains an hour and minute then those two
  6. * fields will be changed in the returned instance.
  7. * Unsupported fields are ignored.
  8. * If the partial is null, then <code>this</code> is returned.
  9. *
  10. * @param partial the partial set of fields to apply to this time, null ignored
  11. * @return a copy of this time with a different set of fields
  12. * @throws IllegalArgumentException if any value is invalid
  13. */
  14. public LocalTime withFields(ReadablePartial partial) {
  15. if (partial == null) {
  16. return this;
  17. }
  18. return withLocalMillis(getChronology().set(partial, getLocalMillis()));
  19. }

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

  1. /**
  2. * Returns a copy of this time with the specified period added.
  3. * <p>
  4. * If the addition is zero, then <code>this</code> is returned.
  5. * <p>
  6. * This method is typically used to add multiple copies of complex
  7. * period instances. Adding one field is best achieved using methods
  8. * like {@link #withFieldAdded(DurationFieldType, int)}
  9. * or {@link #plusHours(int)}.
  10. *
  11. * @param period the period to add to this one, null means zero
  12. * @param scalar the amount of times to add, such as -1 to subtract once
  13. * @return a copy of this time with the period added
  14. * @throws ArithmeticException if the result exceeds the internal capacity
  15. */
  16. public LocalTime withPeriodAdded(ReadablePeriod period, int scalar) {
  17. if (period == null || scalar == 0) {
  18. return this;
  19. }
  20. long instant = getChronology().add(period, getLocalMillis(), scalar);
  21. return withLocalMillis(instant);
  22. }

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

  1. /**
  2. * Adds to this field in a copy of this LocalTime.
  3. * <p>
  4. * The LocalTime attached to this property is unchanged by this call.
  5. *
  6. * @param value the value to add to the field in the copy
  7. * @return a copy of the LocalTime with the field value changed
  8. */
  9. public LocalTime addCopy(int value) {
  10. return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value));
  11. }

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

  1. /**
  2. * Returns a copy of this time with the partial set of fields replacing
  3. * those from this instance.
  4. * <p>
  5. * For example, if the partial contains an hour and minute then those two
  6. * fields will be changed in the returned instance.
  7. * Unsupported fields are ignored.
  8. * If the partial is null, then <code>this</code> is returned.
  9. *
  10. * @param partial the partial set of fields to apply to this time, null ignored
  11. * @return a copy of this time with a different set of fields
  12. * @throws IllegalArgumentException if any value is invalid
  13. */
  14. public LocalTime withFields(ReadablePartial partial) {
  15. if (partial == null) {
  16. return this;
  17. }
  18. return withLocalMillis(getChronology().set(partial, getLocalMillis()));
  19. }

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

  1. /**
  2. * Sets this field in a copy of the LocalTime.
  3. * <p>
  4. * The LocalTime attached to this property is unchanged by this call.
  5. *
  6. * @param value the value to set the field in the copy to
  7. * @return a copy of the LocalTime with the field value changed
  8. * @throws IllegalArgumentException if the value isn't valid
  9. */
  10. public LocalTime setCopy(int value) {
  11. return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value));
  12. }

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

  1. /**
  2. * Returns a copy of this time with the millis of day field updated.
  3. * <p>
  4. * LocalTime is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * millis of day changed.
  7. *
  8. * @param millis the millis of day to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. */
  12. public LocalTime withMillisOfDay(int millis) {
  13. return withLocalMillis(getChronology().millisOfDay().set(getLocalMillis(), millis));
  14. }

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

  1. /**
  2. * Rounds to the nearest whole unit of this field on a copy of this
  3. * LocalTime, favoring the ceiling if halfway.
  4. *
  5. * @return a copy of the LocalTime with the field value changed
  6. */
  7. public LocalTime roundHalfCeilingCopy() {
  8. return iInstant.withLocalMillis(iField.roundHalfCeiling(iInstant.getLocalMillis()));
  9. }

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

  1. /**
  2. * Returns a copy of this time with the second of minute field updated.
  3. * <p>
  4. * LocalTime is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * second of minute changed.
  7. *
  8. * @param second the second of minute to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. */
  12. public LocalTime withSecondOfMinute(int second) {
  13. return withLocalMillis(getChronology().secondOfMinute().set(getLocalMillis(), second));
  14. }

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

  1. /**
  2. * Rounds to the nearest whole unit of this field on a copy of this
  3. * LocalTime. If halfway, the ceiling is favored over the floor
  4. * only if it makes this field's value even.
  5. *
  6. * @return a copy of the LocalTime with the field value changed
  7. */
  8. public LocalTime roundHalfEvenCopy() {
  9. return iInstant.withLocalMillis(iField.roundHalfEven(iInstant.getLocalMillis()));
  10. }
  11. }

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

  1. /**
  2. * Returns a copy of this time with the hour of day field updated.
  3. * <p>
  4. * LocalTime is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * hour of day changed.
  7. *
  8. * @param hour the hour of day to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. */
  12. public LocalTime withHourOfDay(int hour) {
  13. return withLocalMillis(getChronology().hourOfDay().set(getLocalMillis(), hour));
  14. }

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

  1. /**
  2. * Rounds to the highest whole unit of this field on a copy of this
  3. * LocalTime.
  4. * <p>
  5. * For example, rounding floor on the hourOfDay field of a LocalTime
  6. * where the time is 10:30 would result in new LocalTime with the
  7. * time of 11:00.
  8. *
  9. * @return a copy of the LocalTime with the field value changed
  10. */
  11. public LocalTime roundCeilingCopy() {
  12. return iInstant.withLocalMillis(iField.roundCeiling(iInstant.getLocalMillis()));
  13. }

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

  1. /**
  2. * Returns a copy of this time with the minute of hour field updated.
  3. * <p>
  4. * LocalTime is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * minute of hour changed.
  7. *
  8. * @param minute the minute of hour to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. */
  12. public LocalTime withMinuteOfHour(int minute) {
  13. return withLocalMillis(getChronology().minuteOfHour().set(getLocalMillis(), minute));
  14. }

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

  1. /**
  2. * Adds to this field in a copy of this LocalTime.
  3. * <p>
  4. * The LocalTime attached to this property is unchanged by this call.
  5. *
  6. * @param value the value to add to the field in the copy
  7. * @return a copy of the LocalTime with the field value changed
  8. */
  9. public LocalTime addCopy(int value) {
  10. return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value));
  11. }

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

  1. /**
  2. * Returns a copy of this time with the millis of second field updated.
  3. * <p>
  4. * LocalTime is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * millis of second changed.
  7. *
  8. * @param millis the millis of second to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. */
  12. public LocalTime withMillisOfSecond(int millis) {
  13. return withLocalMillis(getChronology().millisOfSecond().set(getLocalMillis(), millis));
  14. }

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

  1. /**
  2. * Rounds to the nearest whole unit of this field on a copy of this
  3. * LocalTime, favoring the floor if halfway.
  4. *
  5. * @return a copy of the LocalTime with the field value changed
  6. */
  7. public LocalTime roundHalfFloorCopy() {
  8. return iInstant.withLocalMillis(iField.roundHalfFloor(iInstant.getLocalMillis()));
  9. }

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

  1. /**
  2. * Returns a copy of this time with the specified period added.
  3. * <p>
  4. * If the addition is zero, then <code>this</code> is returned.
  5. * <p>
  6. * This method is typically used to add multiple copies of complex
  7. * period instances. Adding one field is best achieved using methods
  8. * like {@link #withFieldAdded(DurationFieldType, int)}
  9. * or {@link #plusHours(int)}.
  10. *
  11. * @param period the period to add to this one, null means zero
  12. * @param scalar the amount of times to add, such as -1 to subtract once
  13. * @return a copy of this time with the period added
  14. * @throws ArithmeticException if the result exceeds the internal capacity
  15. */
  16. public LocalTime withPeriodAdded(ReadablePeriod period, int scalar) {
  17. if (period == null || scalar == 0) {
  18. return this;
  19. }
  20. long instant = getChronology().add(period, getLocalMillis(), scalar);
  21. return withLocalMillis(instant);
  22. }

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

  1. /**
  2. * Rounds to the nearest whole unit of this field on a copy of this
  3. * LocalTime, favoring the ceiling if halfway.
  4. *
  5. * @return a copy of the LocalTime with the field value changed
  6. */
  7. public LocalTime roundHalfCeilingCopy() {
  8. return iInstant.withLocalMillis(iField.roundHalfCeiling(iInstant.getLocalMillis()));
  9. }

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

  1. /**
  2. * Returns a copy of this time with the hour of day field updated.
  3. * <p>
  4. * LocalTime is immutable, so there are no set methods.
  5. * Instead, this method returns a new instance with the value of
  6. * hour of day changed.
  7. *
  8. * @param hour the hour of day to set
  9. * @return a copy of this object with the field set
  10. * @throws IllegalArgumentException if the value is invalid
  11. */
  12. public LocalTime withHourOfDay(int hour) {
  13. return withLocalMillis(getChronology().hourOfDay().set(getLocalMillis(), hour));
  14. }

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

  1. /**
  2. * Rounds to the nearest whole unit of this field on a copy of this
  3. * LocalTime. If halfway, the ceiling is favored over the floor
  4. * only if it makes this field's value even.
  5. *
  6. * @return a copy of the LocalTime with the field value changed
  7. */
  8. public LocalTime roundHalfEvenCopy() {
  9. return iInstant.withLocalMillis(iField.roundHalfEven(iInstant.getLocalMillis()));
  10. }
  11. }

相关文章