当前位置: 首页>>代码示例>>Java>>正文


Java WithAdjuster.doWithAdjustment方法代码示例

本文整理汇总了Java中java.time.calendrical.DateTime.WithAdjuster.doWithAdjustment方法的典型用法代码示例。如果您正苦于以下问题:Java WithAdjuster.doWithAdjustment方法的具体用法?Java WithAdjuster.doWithAdjustment怎么用?Java WithAdjuster.doWithAdjustment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.calendrical.DateTime.WithAdjuster的用法示例。


在下文中一共展示了WithAdjuster.doWithAdjustment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
@Override
public Instant with(WithAdjuster adjuster) {

  return (Instant) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:6,代码来源:Instant.java

示例2: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted time based on this time.
 * <p>
 * This adjusts the time according to the rules of the specified adjuster. A simple adjuster might simply
 * set the one of the fields, such as the hour field. A more complex adjuster might set the time to the last
 * hour of the day. The adjuster is responsible for handling special cases, such as the varying lengths of
 * month and leap years.
 * <p>
 * For example, were there to be a class {@code AmPm} implementing the adjuster interface then this method
 * could be used to change the AM/PM value.
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return an {@code OffsetTime} based on this time with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public OffsetTime with(WithAdjuster adjuster) {

  if (adjuster instanceof LocalTime) {
    return with((LocalTime) adjuster, this.offset);
  } else if (adjuster instanceof ZoneOffset) {
    return with(this.time, (ZoneOffset) adjuster);
  } else if (adjuster instanceof OffsetTime) {
    return (OffsetTime) adjuster;
  }
  return (OffsetTime) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:30,代码来源:OffsetTime.java

示例3: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted year-month based on this year-month.
 * <p>
 * This adjusts the year-month according to the rules of the specified adjuster. A simple adjuster might
 * simply set the one of the fields, such as the year field. A more complex adjuster might set the
 * year-month to the next month that Halley's comet will pass the Earth.
 * <p>
 * In addition, all principal classes implement the {@link WithAdjuster} interface, including this one. For
 * example, {@link Month} implements the adjuster interface. As such, this code will compile and run:
 * 
 * <pre>
   *  yearMonth.with(month);
   * </pre>
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return a {@code YearMonth} based on this year-month with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public YearMonth with(WithAdjuster adjuster) {

  if (adjuster instanceof YearMonth) {
    return (YearMonth) adjuster;
  }
  return (YearMonth) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:29,代码来源:YearMonth.java

示例4: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted date-time based on this date-time.
 * <p>
 * This adjusts the date-time according to the rules of the specified adjuster. A simple adjuster might
 * simply set the one of the fields, such as the year field. A more complex adjuster might set the date-time
 * to the last day of the month. A selection of common adjustments is provided in {@link DateTimeAdjusters}.
 * These include finding the "last day of the month" and "next Wednesday". The adjuster is responsible for
 * handling special cases, such as the varying lengths of month and leap years.
 * <p>
 * In addition, all principal classes implement the {@link WithAdjuster} interface, including this one. For
 * example, {@link LocalDate} implements the adjuster interface. As such, this code will compile and run:
 * 
 * <pre>
   *  dateTime.with(date);
   * </pre>
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return an {@code OffsetDateTime} based on this date-time with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public OffsetDateTime with(WithAdjuster adjuster) {

  if (adjuster instanceof LocalDate || adjuster instanceof LocalTime || adjuster instanceof LocalDateTime) {
    return with(this.dateTime.with(adjuster), this.offset);
  } else if (adjuster instanceof ZoneOffset) {
    return with(this.dateTime, (ZoneOffset) adjuster);
  } else if (adjuster instanceof OffsetDateTime) {
    return (OffsetDateTime) adjuster;
  }
  return (OffsetDateTime) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:35,代码来源:OffsetDateTime.java

示例5: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted time based on this time.
 * <p>
 * This adjusts the time according to the rules of the specified adjuster. A simple adjuster might simply
 * set the one of the fields, such as the hour field. A more complex adjuster might set the time to the last
 * hour of the day. The adjuster is responsible for handling special cases, such as the varying lengths of
 * month and leap years.
 * <p>
 * For example, were there to be a class {@code AmPm} implementing the adjuster interface then this method
 * could be used to change the AM/PM value.
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return a {@code LocalTime} based on this time with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public LocalTime with(WithAdjuster adjuster) {

  if (adjuster instanceof LocalTime) {
    return (LocalTime) adjuster;
  }
  return (LocalTime) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:26,代码来源:LocalTime.java

示例6: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted date based on this date.
 * <p>
 * This adjusts the date according to the rules of the specified adjuster. A simple adjuster might simply
 * set the one of the fields, such as the year field. A more complex adjuster might set the date to the last
 * day of the month. A selection of common adjustments is provided in {@link DateTimeAdjusters}. These
 * include finding the "last day of the month" and "next Wednesday". The adjuster is responsible for
 * handling special cases, such as the varying lengths of month and leap years.
 * <p>
 * In addition, all principal classes implement the {@link WithAdjuster} interface, including this one. For
 * example, {@link Month} implements the adjuster interface. As such, this code will compile and run:
 * 
 * <pre>
   *  date.with(Month.JULY);
   * </pre>
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return a {@code LocalDate} based on this date with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public LocalDate with(WithAdjuster adjuster) {

  if (adjuster instanceof LocalDate) {
    return (LocalDate) adjuster;
  }
  return (LocalDate) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:31,代码来源:LocalDate.java

示例7: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted date-time based on this date-time.
 * <p>
 * This adjusts the date-time according to the rules of the specified adjuster. A simple adjuster might
 * simply set the one of the fields, such as the year field. A more complex adjuster might set the date-time
 * to the last day of the month. A selection of common adjustments is provided in {@link DateTimeAdjusters}.
 * These include finding the "last day of the month" and "next Wednesday". The adjuster is responsible for
 * handling special cases, such as the varying lengths of month and leap years.
 * <p>
 * In addition, all principal classes implement the {@link WithAdjuster} interface, including this one. For
 * example, {@link LocalDate} implements the adjuster interface. As such, this code will compile and run:
 * 
 * <pre>
   *  dateTime.with(date);
   * </pre>
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return a {@code LocalDateTime} based on this date-time with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public LocalDateTime with(WithAdjuster adjuster) {

  if (adjuster instanceof LocalDate) {
    return with((LocalDate) adjuster, this.time);
  } else if (adjuster instanceof LocalTime) {
    return with(this.date, (LocalTime) adjuster);
  } else if (adjuster instanceof LocalDateTime) {
    return (LocalDateTime) adjuster;
  }
  return (LocalDateTime) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:35,代码来源:LocalDateTime.java

示例8: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted year based on this year.
 * <p>
 * This adjusts the year according to the rules of the specified adjuster.
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return a {@code LocalDate} based on this date with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public Year with(WithAdjuster adjuster) {

  if (adjuster instanceof Year) {
    return (Year) adjuster;
  }
  return (Year) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:20,代码来源:Year.java

示例9: with

import java.time.calendrical.DateTime.WithAdjuster; //导入方法依赖的package包/类
/**
 * Returns an adjusted date based on this date.
 * <p>
 * This adjusts the date according to the rules of the specified adjuster. A simple adjuster might simply
 * set the one of the fields, such as the year field. A more complex adjuster might set the date to the last
 * day of the month. A selection of common adjustments is provided in {@link DateTimeAdjusters}. These
 * include finding the "last day of the month" and "next Wednesday". The adjuster is responsible for
 * handling special cases, such as the varying lengths of month and leap years.
 * <p>
 * In addition, all principal classes implement the {@link WithAdjuster} interface, including this one. For
 * example, {@link Month} implements the adjuster interface. As such, this code will compile and run:
 * 
 * <pre>
   *  date.with(Month.JULY);
   * </pre>
 * <p>
 * This instance is immutable and unaffected by this method call.
 * 
 * @param adjuster the adjuster to use, not null
 * @return an {@code OffsetDate} based on this date with the adjustment made, not null
 * @throws DateTimeException if the adjustment cannot be made
 */
@Override
public OffsetDate with(WithAdjuster adjuster) {

  if (adjuster instanceof LocalDate) {
    return with((LocalDate) adjuster, this.offset);
  } else if (adjuster instanceof ZoneOffset) {
    return with(this.date, (ZoneOffset) adjuster);
  } else if (adjuster instanceof OffsetDate) {
    return (OffsetDate) adjuster;
  }
  return (OffsetDate) adjuster.doWithAdjustment(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:35,代码来源:OffsetDate.java


注:本文中的java.time.calendrical.DateTime.WithAdjuster.doWithAdjustment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。