本文整理汇总了Java中java.time.calendrical.DateTime.with方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.with方法的具体用法?Java DateTime.with怎么用?Java DateTime.with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.calendrical.DateTime
的用法示例。
在下文中一共展示了DateTime.with方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doWithAdjustment
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Override
public DateTime doWithAdjustment(DateTime dateTime) {
return dateTime.with(NANO_OF_DAY, toNanoOfDay());
}
示例2: doWithAdjustment
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Override
public DateTime doWithAdjustment(DateTime dateTime) {
return dateTime.with(EPOCH_DAY, toEpochDay());
}
示例3: doWithAdjustment
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Override
public DateTime doWithAdjustment(DateTime dateTime) {
return dateTime.with(OFFSET_SECONDS, this.totalSeconds);
}
示例4: doWithAdjustment
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
@Override
public DateTime doWithAdjustment(DateTime dateTime) {
return dateTime.with(ERA, getValue());
}
示例5: doWithAdjustment
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
/**
* Implementation of the strategy to make an adjustment to the specified date-time object.
* <p>
* This method is not intended to be called by application code directly. Applications should use the
* {@code with(WithAdjuster)} method on the date-time object to make the adjustment passing this as the
* argument.
* <p>
* This instance is immutable and unaffected by this method call.
*
* <h4>Implementation notes</h4>
* Adjusts the specified date-time to have the value of this year-month. The date-time object must use the
* ISO calendar system. The adjustment is equivalent to using {@link DateTime#with(DateTimeField, long)}
* passing {@code EPOCH_MONTH} as the field.
*
* @param dateTime the target object to be adjusted, not null
* @return the adjusted object, not null
*/
@Override
public DateTime doWithAdjustment(DateTime dateTime) {
if (Chrono.from(dateTime).equals(ISOChrono.INSTANCE) == false) {
throw new DateTimeException("Adjustment only supported on ISO date-time");
}
return dateTime.with(EPOCH_MONTH, getEpochMonth());
}
示例6: doWithAdjustment
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
/**
* Implementation of the strategy to make an adjustment to the specified date-time object.
* <p>
* This method is not intended to be called by application code directly. Applications should use the
* {@code with(WithAdjuster)} method on the date-time object to make the adjustment passing this as the
* argument.
* <p>
* This instance is immutable and unaffected by this method call.
*
* <h4>Implementation notes</h4>
* Adjusts the specified date-time to have the value of this month-day. The date-time object must use the
* ISO calendar system. The adjustment is equivalent to using {@link DateTime#with(DateTimeField, long)}
* twice passing {@code MONTH_OF_YEAR} and {@code DAY_OF_MONTH} as the fields.
*
* @param dateTime the target object to be adjusted, not null
* @return the adjusted object, not null
*/
@Override
public DateTime doWithAdjustment(DateTime dateTime) {
if (Chrono.from(dateTime).equals(ISOChrono.INSTANCE) == false) {
throw new DateTimeException("Adjustment only supported on ISO date-time");
}
dateTime = dateTime.with(MONTH_OF_YEAR, this.month);
return dateTime.with(DAY_OF_MONTH, Math.min(dateTime.range(DAY_OF_MONTH).getMaximum(), this.day));
}
示例7: doWithAdjustment
import java.time.calendrical.DateTime; //导入方法依赖的package包/类
/**
* Implementation of the strategy to make an adjustment to the specified date-time object.
* <p>
* This method is not intended to be called by application code directly. Applications should use the
* {@code with(WithAdjuster)} method on the date-time object to make the adjustment passing this as the
* argument.
* <p>
* This instance is immutable and unaffected by this method call.
*
* <h4>Implementation notes</h4>
* Adjusts the specified date-time to have the value of this year. The date-time object must use the ISO
* calendar system. The adjustment is equivalent to using {@link DateTime#with(DateTimeField, long)} passing
* {@code YEAR} as the field.
*
* @param dateTime the target object to be adjusted, not null
* @return the adjusted object, not null
*/
@Override
public DateTime doWithAdjustment(DateTime dateTime) {
if (Chrono.from(dateTime).equals(ISOChrono.INSTANCE) == false) {
throw new DateTimeException("Adjustment only supported on ISO date-time");
}
return dateTime.with(YEAR, this.year);
}