Java 类java.time.calendrical.DateTime.WithAdjuster 实例源码

项目:optashift-employee-rostering    文件:ChronoDateTimeImpl.java   
@SuppressWarnings("unchecked")
@Override
public ChronoDateTimeImpl<C> with(WithAdjuster adjuster) {

  if (adjuster instanceof ChronoLocalDate) {
    // The Chrono is checked in with(date,time)
    return with((ChronoLocalDate<C>) adjuster, this.time);
  } else if (adjuster instanceof LocalTime) {
    return with(this.date, (LocalTime) adjuster);
  } else if (adjuster instanceof ChronoDateTimeImpl) {
    return this.date.getChrono().ensureChronoLocalDateTime((ChronoDateTimeImpl<?>) adjuster);
  }
  return this.date.getChrono().ensureChronoLocalDateTime(adjuster.doWithAdjustment(this));
}
项目:gwt-time    文件:ChronoDateTimeImpl.java   
@SuppressWarnings("unchecked")
@Override
public ChronoDateTimeImpl<C> with(WithAdjuster adjuster) {

  if (adjuster instanceof ChronoLocalDate) {
    // The Chrono is checked in with(date,time)
    return with((ChronoLocalDate<C>) adjuster, this.time);
  } else if (adjuster instanceof LocalTime) {
    return with(this.date, (LocalTime) adjuster);
  } else if (adjuster instanceof ChronoDateTimeImpl) {
    return this.date.getChrono().ensureChronoLocalDateTime((ChronoDateTimeImpl<?>) adjuster);
  }
  return this.date.getChrono().ensureChronoLocalDateTime(adjuster.doWithAdjustment(this));
}
项目:java8-backports    文件:ChronoDateTimeImpl.java   
@SuppressWarnings("unchecked")
@Override
public ChronoDateTimeImpl<C> with(WithAdjuster adjuster) {

  if (adjuster instanceof ChronoLocalDate) {
    // The Chrono is checked in with(date,time)
    return with((ChronoLocalDate<C>) adjuster, this.time);
  } else if (adjuster instanceof LocalTime) {
    return with(this.date, (LocalTime) adjuster);
  } else if (adjuster instanceof ChronoDateTimeImpl) {
    return this.date.getChrono().ensureChronoLocalDateTime((ChronoDateTimeImpl<?>) adjuster);
  }
  return this.date.getChrono().ensureChronoLocalDateTime(adjuster.doWithAdjustment(this));
}
项目:java8-backports    文件:TCKOffsetDateTime.java   
@Test(groups = { "tck" })
public void test_with_adjustment() {

  final OffsetDateTime sample = OffsetDateTime.of(2012, 3, 4, 23, 5, OFFSET_PONE);
  WithAdjuster adjuster = new WithAdjuster() {

    @Override
    public DateTime doWithAdjustment(DateTime dateTime) {

      return sample;
    }
  };
  assertEquals(this.TEST_2008_6_30_11_30_59_000000500.with(adjuster), sample);
}
项目:java8-backports    文件:TCKLocalDateTime.java   
@Test(groups = { "tck" })
public void test_with_adjustment() {

  final LocalDateTime sample = LocalDateTime.of(2012, 3, 4, 23, 5);
  WithAdjuster adjuster = new WithAdjuster() {

    @Override
    public DateTime doWithAdjustment(DateTime dateTime) {

      return sample;
    }
  };
  assertEquals(this.TEST_2007_07_15_12_30_40_987654321.with(adjuster), sample);
}
项目:java8-backports    文件:TCKLocalDate.java   
@Test(groups = { "tck" })
public void test_with_adjustment() {

  final LocalDate sample = LocalDate.of(2012, 3, 4);
  WithAdjuster adjuster = new WithAdjuster() {

    @Override
    public DateTime doWithAdjustment(DateTime dateTime) {

      return sample;
    }
  };
  assertEquals(this.TEST_2007_07_15.with(adjuster), sample);
}
项目:java8-backports    文件:TCKLocalTime.java   
@Test(groups = { "tck" })
public void test_with_adjustment() {

  final LocalTime sample = LocalTime.of(23, 5);
  WithAdjuster adjuster = new WithAdjuster() {

    @Override
    public DateTime doWithAdjustment(DateTime dateTime) {

      return sample;
    }
  };
  assertEquals(this.TEST_12_30_40_987654321.with(adjuster), sample);
}
项目:java8-backports    文件:TCKOffsetDate.java   
@Test(groups = { "tck" })
public void test_with_adjustment() {

  final OffsetDate sample = OffsetDate.of(2012, 3, 4, OFFSET_PONE);
  WithAdjuster adjuster = new WithAdjuster() {

    @Override
    public DateTime doWithAdjustment(DateTime dateTime) {

      return sample;
    }
  };
  assertEquals(this.TEST_2007_07_15_PONE.with(adjuster), sample);
}
项目:java8-backports    文件:TCKOffsetTime.java   
@Test(groups = { "tck" })
public void test_with_adjustment() {

  final OffsetTime sample = OffsetTime.of(23, 5, OFFSET_PONE);
  WithAdjuster adjuster = new WithAdjuster() {

    @Override
    public DateTime doWithAdjustment(DateTime dateTime) {

      return sample;
    }
  };
  assertEquals(this.TEST_11_30_59_500_PONE.with(adjuster), sample);
}
项目:java8-backports    文件:TCKOffsetTime.java   
@Test(groups = { "tck" })
public void test_with_adjustment_AmPm() {

  OffsetTime test = this.TEST_11_30_59_500_PONE.with(new WithAdjuster() {

    @Override
    public DateTime doWithAdjustment(DateTime dateTime) {

      return dateTime.with(HOUR_OF_DAY, 23);
    }
  });
  assertEquals(test, OffsetTime.of(23, 30, 59, 500, OFFSET_PONE));
}
项目:java8-backports    文件:TestMonthDay.java   
@Test(groups = { "implementation" })
public void test_interfaces() {

  Object obj = this.TEST_07_15;
  assertTrue(obj instanceof Serializable);
  assertTrue(obj instanceof Comparable<?>);
  assertTrue(obj instanceof WithAdjuster);
}
项目:java8-backports    文件:TestYear.java   
@Test(groups = { "implementation" })
public void test_interfaces() {

  assertTrue(Serializable.class.isAssignableFrom(Year.class));
  assertTrue(Comparable.class.isAssignableFrom(Year.class));
  assertTrue(WithAdjuster.class.isAssignableFrom(Year.class));
}
项目:java8-backports    文件:TestYearMonth.java   
@Test(groups = { "implementation" })
public void test_interfaces() {

  Object obj = this.TEST_2008_06;
  assertTrue(obj instanceof Serializable);
  assertTrue(obj instanceof Comparable<?>);
  assertTrue(obj instanceof WithAdjuster);
}
项目:optashift-employee-rostering    文件:Instant.java   
@Override
public Instant with(WithAdjuster adjuster) {

  return (Instant) adjuster.doWithAdjustment(this);
}
项目:optashift-employee-rostering    文件:ChronoLocalDate.java   
@Override
ChronoLocalDate<C> with(WithAdjuster adjuster);
项目:optashift-employee-rostering    文件:ChronoLocalDateTime.java   
@Override
ChronoLocalDateTime<C> with(WithAdjuster adjuster);
项目:gwt-time    文件:Instant.java   
@Override
public Instant with(WithAdjuster adjuster) {

  return (Instant) adjuster.doWithAdjustment(this);
}
项目:gwt-time    文件:ChronoLocalDate.java   
@Override
ChronoLocalDate<C> with(WithAdjuster adjuster);
项目:gwt-time    文件:ChronoLocalDateTime.java   
@Override
ChronoLocalDateTime<C> with(WithAdjuster adjuster);
项目:java8-backports    文件:Instant.java   
@Override
public Instant with(WithAdjuster adjuster) {

  return (Instant) adjuster.doWithAdjustment(this);
}
项目:java8-backports    文件:ChronoLocalDate.java   
@Override
ChronoLocalDate<C> with(WithAdjuster adjuster);
项目:java8-backports    文件:ChronoLocalDateTime.java   
@Override
ChronoLocalDateTime<C> with(WithAdjuster adjuster);
项目:java8-backports    文件:TCKZonedDateTime.java   
@Test(expectedExceptions = NullPointerException.class, groups = { "tck" })
public void test_with_WithAdjuster_null() {

  ZonedDateTime base = ZonedDateTime.of(this.TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
  base.with((WithAdjuster) null);
}
项目:java8-backports    文件:TCKOffsetDateTime.java   
@Test(expectedExceptions = NullPointerException.class, groups = { "tck" })
public void test_with_adjustment_null() {

  this.TEST_2008_6_30_11_30_59_000000500.with((WithAdjuster) null);
}
项目:java8-backports    文件:TCKLocalDateTime.java   
@Test(expectedExceptions = NullPointerException.class, groups = { "tck" })
public void test_with_adjustment_null() {

  this.TEST_2007_07_15_12_30_40_987654321.with((WithAdjuster) null);
}
项目:java8-backports    文件:TCKLocalDate.java   
@Test(expectedExceptions = NullPointerException.class, groups = { "tck" })
public void test_with_adjustment_null() {

  this.TEST_2007_07_15.with((WithAdjuster) null);
}
项目:java8-backports    文件:TCKLocalTime.java   
@Test(expectedExceptions = NullPointerException.class, groups = { "tck" })
public void test_with_adjustment_null() {

  this.TEST_12_30_40_987654321.with((WithAdjuster) null);
}
项目:java8-backports    文件:TCKOffsetDate.java   
@Test(expectedExceptions = NullPointerException.class, groups = { "tck" })
public void test_with_adjustment_null() {

  this.TEST_2007_07_15_PONE.with((WithAdjuster) null);
}
项目:java8-backports    文件:TCKOffsetTime.java   
@Test(expectedExceptions = NullPointerException.class, groups = { "tck" })
public void test_with_adjustment_null() {

  this.TEST_11_30_59_500_PONE.with((WithAdjuster) null);
}
项目:optashift-employee-rostering    文件:OffsetTime.java   
/**
 * 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);
}
项目:optashift-employee-rostering    文件:YearMonth.java   
/**
 * 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);
}
项目:optashift-employee-rostering    文件:OffsetDateTime.java   
/**
 * 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);
}
项目:optashift-employee-rostering    文件:LocalTime.java   
/**
 * 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);
}
项目:optashift-employee-rostering    文件:LocalDate.java   
/**
 * 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);
}
项目:optashift-employee-rostering    文件:LocalDateTime.java   
/**
 * 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);
}
项目:optashift-employee-rostering    文件:Year.java   
/**
 * 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);
}
项目:optashift-employee-rostering    文件:OffsetDate.java   
/**
 * 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);
}
项目:gwt-time    文件:OffsetTime.java   
/**
 * 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);
}
项目:gwt-time    文件:YearMonth.java   
/**
 * 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);
}
项目:gwt-time    文件:OffsetDateTime.java   
/**
 * 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);
}