本文整理了Java中org.joda.time.LocalDateTime.withLocalMillis()
方法的一些代码示例,展示了LocalDateTime.withLocalMillis()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDateTime.withLocalMillis()
方法的具体详情如下:
包路径:org.joda.time.LocalDateTime
类名称:LocalDateTime
方法名:withLocalMillis
[英]Returns a copy of this datetime 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
.
[中]返回具有不同本地毫秒数的此datetime的副本。
返回的对象将是相同类型的新实例。只有米利会改变,年表会保留下来。返回的对象将是新实例或this
。
代码示例来源:origin: joda-time/joda-time
/**
* Sets this field in a copy of the LocalDateTime.
* <p>
* The LocalDateTime attached to this property is unchanged by this call.
*
* @param value the value to set the field in the copy to
* @return a copy of the LocalDateTime with the field value changed
* @throws IllegalArgumentException if the value isn't valid
*/
public LocalDateTime setCopy(int value) {
return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the minute of hour field updated.
* <p>
* LocalDateTime is immutable, so there are no set methods.
* Instead, this method returns a new instance with the value of
* minute of hour changed.
*
* @param minute the minute of hour to set
* @return a copy of this object with the field set
* @throws IllegalArgumentException if the value is invalid
*/
public LocalDateTime withMinuteOfHour(int minute) {
return withLocalMillis(getChronology().minuteOfHour().set(getLocalMillis(), minute));
}
代码示例来源:origin: joda-time/joda-time
/**
* Adds to this field in a copy of this LocalDateTime.
* <p>
* The LocalDateTime attached to this property is unchanged by this call.
*
* @param value the value to add to the field in the copy
* @return a copy of the LocalDateTime with the field value changed
* @throws IllegalArgumentException if the value isn't valid
*/
public LocalDateTime addToCopy(int value) {
return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the partial set of fields
* replacing those from this instance.
* <p>
* For example, if the partial is a <code>TimeOfDay</code> then the time fields
* would be changed in the returned instance.
* If the partial is null, then <code>this</code> is returned.
*
* @param partial the partial set of fields to apply to this datetime, null ignored
* @return a copy of this datetime with a different set of fields
* @throws IllegalArgumentException if any value is invalid
*/
public LocalDateTime withFields(ReadablePartial partial) {
if (partial == null) {
return this;
}
return withLocalMillis(getChronology().set(partial, getLocalMillis()));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the century of era field updated.
* <p>
* LocalDateTime is immutable, so there are no set methods.
* Instead, this method returns a new instance with the value of
* century of era changed.
*
* @param centuryOfEra the century of era to set
* @return a copy of this object with the field set
* @throws IllegalArgumentException if the value is invalid
*/
public LocalDateTime withCenturyOfEra(int centuryOfEra) {
return withLocalMillis(getChronology().centuryOfEra().set(getLocalMillis(), centuryOfEra));
}
代码示例来源:origin: JodaOrg/joda-time
/**
* Returns a copy of this datetime with the partial set of fields
* replacing those from this instance.
* <p>
* For example, if the partial is a <code>TimeOfDay</code> then the time fields
* would be changed in the returned instance.
* If the partial is null, then <code>this</code> is returned.
*
* @param partial the partial set of fields to apply to this datetime, null ignored
* @return a copy of this datetime with a different set of fields
* @throws IllegalArgumentException if any value is invalid
*/
public LocalDateTime withFields(ReadablePartial partial) {
if (partial == null) {
return this;
}
return withLocalMillis(getChronology().set(partial, getLocalMillis()));
}
代码示例来源:origin: joda-time/joda-time
/**
* Sets this field in a copy of the LocalDateTime to a parsed text value.
* <p>
* The LocalDateTime attached to this property is unchanged by this call.
*
* @param text the text value to set
* @param locale optional locale to use for selecting a text symbol
* @return a copy of the LocalDateTime with the field value changed
* @throws IllegalArgumentException if the text value isn't valid
*/
public LocalDateTime setCopy(String text, Locale locale) {
return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), text, locale));
}
代码示例来源:origin: joda-time/joda-time
/**
* Rounds to the nearest whole unit of this field on a copy of this
* LocalDateTime, favoring the ceiling if halfway.
*
* @return a copy of the LocalDateTime with the field value changed
*/
public LocalDateTime roundHalfCeilingCopy() {
return iInstant.withLocalMillis(iField.roundHalfCeiling(iInstant.getLocalMillis()));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the year of era field updated.
* <p>
* LocalDateTime is immutable, so there are no set methods.
* Instead, this method returns a new instance with the value of
* year of era changed.
*
* @param yearOfEra the year of era to set
* @return a copy of this object with the field set
* @throws IllegalArgumentException if the value is invalid
*/
public LocalDateTime withYearOfEra(int yearOfEra) {
return withLocalMillis(getChronology().yearOfEra().set(getLocalMillis(), yearOfEra));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the specified period added.
* <p>
* If the addition is zero, then <code>this</code> is returned.
* <p>
* This method is typically used to add multiple copies of complex
* period instances. Adding one field is best achieved using methods
* like {@link #withFieldAdded(DurationFieldType, int)}
* or {@link #plusYears(int)}.
*
* @param period the period to add to this one, null means zero
* @param scalar the amount of times to add, such as -1 to subtract once
* @return a copy of this datetime with the period added
* @throws ArithmeticException if the result exceeds the internal capacity
*/
public LocalDateTime withPeriodAdded(ReadablePeriod period, int scalar) {
if (period == null || scalar == 0) {
return this;
}
long instant = getChronology().add(period, getLocalMillis(), scalar);
return withLocalMillis(instant);
}
代码示例来源:origin: JodaOrg/joda-time
/**
* Sets this field in a copy of the LocalDateTime.
* <p>
* The LocalDateTime attached to this property is unchanged by this call.
*
* @param value the value to set the field in the copy to
* @return a copy of the LocalDateTime with the field value changed
* @throws IllegalArgumentException if the value isn't valid
*/
public LocalDateTime setCopy(int value) {
return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value));
}
代码示例来源:origin: joda-time/joda-time
/**
* Adds to this field in a copy of this LocalDateTime.
* <p>
* The LocalDateTime attached to this property is unchanged by this call.
*
* @param value the value to add to the field in the copy
* @return a copy of the LocalDateTime with the field value changed
* @throws IllegalArgumentException if the value isn't valid
*/
public LocalDateTime addToCopy(long value) {
return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the year field updated.
* <p>
* LocalDateTime is immutable, so there are no set methods.
* Instead, this method returns a new instance with the value of
* year changed.
*
* @param year the year to set
* @return a copy of this object with the field set
* @throws IllegalArgumentException if the value is invalid
*/
public LocalDateTime withYear(int year) {
return withLocalMillis(getChronology().year().set(getLocalMillis(), year));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the specified duration added.
* <p>
* If the addition is zero, then <code>this</code> is returned.
*
* @param durationToAdd the duration to add to this one, null means zero
* @param scalar the amount of times to add, such as -1 to subtract once
* @return a copy of this datetime with the duration added
* @throws ArithmeticException if the result exceeds the internal capacity
*/
public LocalDateTime withDurationAdded(ReadableDuration durationToAdd, int scalar) {
if (durationToAdd == null || scalar == 0) {
return this;
}
long instant = getChronology().add(getLocalMillis(), durationToAdd.getMillis(), scalar);
return withLocalMillis(instant);
}
代码示例来源:origin: JodaOrg/joda-time
/**
* Sets this field in a copy of the LocalDateTime to a parsed text value.
* <p>
* The LocalDateTime attached to this property is unchanged by this call.
*
* @param text the text value to set
* @param locale optional locale to use for selecting a text symbol
* @return a copy of the LocalDateTime with the field value changed
* @throws IllegalArgumentException if the text value isn't valid
*/
public LocalDateTime setCopy(String text, Locale locale) {
return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), text, locale));
}
代码示例来源:origin: joda-time/joda-time
/**
* Rounds to the nearest whole unit of this field on a copy of this
* LocalDateTime, favoring the floor if halfway.
*
* @return a copy of the LocalDateTime with the field value changed
*/
public LocalDateTime roundHalfFloorCopy() {
return iInstant.withLocalMillis(iField.roundHalfFloor(iInstant.getLocalMillis()));
}
代码示例来源:origin: joda-time/joda-time
/**
* Returns a copy of this datetime with the day of week field updated.
* <p>
* LocalDateTime is immutable, so there are no set methods.
* Instead, this method returns a new instance with the value of
* day of week changed.
*
* @param dayOfWeek the day of week to set
* @return a copy of this object with the field set
* @throws IllegalArgumentException if the value is invalid
*/
public LocalDateTime withDayOfWeek(int dayOfWeek) {
return withLocalMillis(getChronology().dayOfWeek().set(getLocalMillis(), dayOfWeek));
}
代码示例来源:origin: JodaOrg/joda-time
/**
* Returns a copy of this datetime with the specified duration added.
* <p>
* If the addition is zero, then <code>this</code> is returned.
*
* @param durationToAdd the duration to add to this one, null means zero
* @param scalar the amount of times to add, such as -1 to subtract once
* @return a copy of this datetime with the duration added
* @throws ArithmeticException if the result exceeds the internal capacity
*/
public LocalDateTime withDurationAdded(ReadableDuration durationToAdd, int scalar) {
if (durationToAdd == null || scalar == 0) {
return this;
}
long instant = getChronology().add(getLocalMillis(), durationToAdd.getMillis(), scalar);
return withLocalMillis(instant);
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Sets this field in a copy of the LocalDateTime.
* <p>
* The LocalDateTime attached to this property is unchanged by this call.
*
* @param value the value to set the field in the copy to
* @return a copy of the LocalDateTime with the field value changed
* @throws IllegalArgumentException if the value isn't valid
*/
public LocalDateTime setCopy(int value) {
return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value));
}
代码示例来源:origin: joda-time/joda-time
/**
* Rounds to the nearest whole unit of this field on a copy of this
* LocalDateTime. If halfway, the ceiling is favored over the floor
* only if it makes this field's value even.
*
* @return a copy of the LocalDateTime with the field value changed
*/
public LocalDateTime roundHalfEvenCopy() {
return iInstant.withLocalMillis(iField.roundHalfEven(iInstant.getLocalMillis()));
}
}
内容来源于网络,如有侵权,请联系作者删除!