當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTime.with方法代碼示例

本文整理匯總了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());
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:6,代碼來源:LocalTime.java

示例2: doWithAdjustment

import java.time.calendrical.DateTime; //導入方法依賴的package包/類
@Override
public DateTime doWithAdjustment(DateTime dateTime) {

  return dateTime.with(EPOCH_DAY, toEpochDay());
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:6,代碼來源:DefaultInterfaceChronoLocalDate.java

示例3: doWithAdjustment

import java.time.calendrical.DateTime; //導入方法依賴的package包/類
@Override
public DateTime doWithAdjustment(DateTime dateTime) {

  return dateTime.with(OFFSET_SECONDS, this.totalSeconds);
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:6,代碼來源:ZoneOffset.java

示例4: doWithAdjustment

import java.time.calendrical.DateTime; //導入方法依賴的package包/類
@Override
public DateTime doWithAdjustment(DateTime dateTime) {

  return dateTime.with(ERA, getValue());
}
 
開發者ID:m-m-m,項目名稱:java8-backports,代碼行數:6,代碼來源:DefaultInterfaceEra.java

示例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());
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:26,代碼來源:YearMonth.java

示例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));
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:27,代碼來源:MonthDay.java

示例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);
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:26,代碼來源:Year.java


注:本文中的java.time.calendrical.DateTime.with方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。