Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove OffsetDateTime.withDate() and withTime()

Reduce scope
  • Loading branch information...
commit 26f14d3e301948ee659acf90af15d66fe6b1ec22 1 parent aa8cea8
@jodastephen jodastephen authored
View
97 src/main/java/javax/time/OffsetDateTime.java
@@ -862,45 +862,6 @@ public OffsetDateTime withDayOfYear(int dayOfYear) {
//-----------------------------------------------------------------------
/**
- * Returns a copy of this {@code OffsetDateTime} with the date values altered.
- * <p>
- * This method will return a new instance with the same time fields,
- * but altered date fields.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param year the year to set in the result, from MIN_YEAR to MAX_YEAR
- * @param month the month-of-year to set in the result, not null
- * @param dayOfMonth the day-of-month to set in the result, from 1 to 31
- * @return an {@code OffsetDateTime} based on this date-time with the requested date, not null
- * @throws DateTimeException if any field value is invalid
- * @throws DateTimeException if the day-of-month is invalid for the month-year
- */
- public OffsetDateTime withDate(int year, Month month, int dayOfMonth) {
- return with(dateTime.withDate(year, month, dayOfMonth), offset);
- }
-
- /**
- * Returns a copy of this {@code OffsetDateTime} with the date values altered.
- * <p>
- * This method will return a new instance with the same time fields,
- * but altered date fields.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param year the year to set in the result, from MIN_VALUE + 1 to MAX_VALUE
- * @param month the month-of-year to set in the result, from 1 (January) to 12 (December)
- * @param dayOfMonth the day-of-month to set in the result, from 1 to 31
- * @return an {@code OffsetDateTime} based on this date-time with the requested date, not null
- * @throws DateTimeException if any field value is invalid
- * @throws DateTimeException if the day-of-month is invalid for the month-year
- */
- public OffsetDateTime withDate(int year, int month, int dayOfMonth) {
- return with(dateTime.withDate(year, month, dayOfMonth), offset);
- }
-
- //-----------------------------------------------------------------------
- /**
* Returns a copy of this {@code OffsetDateTime} with the hour-of-day value altered.
* <p>
* This instance is immutable and unaffected by this method call.
@@ -956,64 +917,6 @@ public OffsetDateTime withNano(int nanoOfSecond) {
return (newDT == dateTime ? this : new OffsetDateTime(newDT, offset));
}
- /**
- * Returns a copy of this {@code OffsetDateTime} with the time values altered.
- * <p>
- * This method will return a new instance with the same date fields,
- * but altered time fields.
- * This is a shorthand for {@link #withTime(int,int,int,int)} and sets
- * the second and nanosecond fields to zero.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param hour the hour-of-day to set in the result, from 0 to 23
- * @param minute the minute-of-hour to set in the result, from 0 to 59
- * @return an {@code OffsetDateTime} based on this date-time with the requested time, not null
- * @throws DateTimeException if any field value is invalid
- */
- public OffsetDateTime withTime(int hour, int minute) {
- LocalDateTime newDT = dateTime.withTime(hour, minute);
- return (newDT == dateTime ? this : new OffsetDateTime(newDT, offset));
- }
-
- /**
- * Returns a copy of this {@code OffsetDateTime} with the time values altered.
- * <p>
- * This method will return a new instance with the same date fields,
- * but altered time fields.
- * This is a shorthand for {@link #withTime(int,int,int,int)} and sets
- * the nanosecond fields to zero.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param hour the hour-of-day to set in the result, from 0 to 23
- * @param minute the minute-of-hour to set in the result, from 0 to 59
- * @param second the second-of-minute to set in the result, from 0 to 59
- * @return an {@code OffsetDateTime} based on this date-time with the requested time, not null
- * @throws DateTimeException if any field value is invalid
- */
- public OffsetDateTime withTime(int hour, int minute, int second) {
- LocalDateTime newDT = dateTime.withTime(hour, minute, second);
- return (newDT == dateTime ? this : new OffsetDateTime(newDT, offset));
- }
-
- /**
- * Returns a copy of this OffsetDateTime with the time values altered.
- * <p>
- * This instance is immutable and unaffected by this method call.
- *
- * @param hour the hour-of-day to set in the result, from 0 to 23
- * @param minute the minute-of-hour to set in the result, from 0 to 59
- * @param second the second-of-minute to set in the result, from 0 to 59
- * @param nanoOfSecond the nano-of-second to set in the result, from 0 to 999,999,999
- * @return an {@code OffsetDateTime} based on this date-time with the requested time, not null
- * @throws DateTimeException if any field value is invalid
- */
- public OffsetDateTime withTime(int hour, int minute, int second, int nanoOfSecond) {
- LocalDateTime newDT = dateTime.withTime(hour, minute, second, nanoOfSecond);
- return (newDT == dateTime ? this : new OffsetDateTime(newDT, offset));
- }
-
//-----------------------------------------------------------------------
/**
* Returns a copy of this date-time with the specified period added.
View
40 src/tck/java/javax/time/TCKOffsetDateTime.java
@@ -784,17 +784,6 @@ public void test_withDayOfYear_invalid() {
}
//-----------------------------------------------------------------------
- // withDate()
- //-----------------------------------------------------------------------
- @Test(groups={"tck"})
- public void test_withDate() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, OFFSET_PONE);
- OffsetDateTime test = base.withDate(2007, 1, 1);
- OffsetDateTime expected = OffsetDateTime.of(2007, 1, 1, 11, 30, 59, OFFSET_PONE);
- assertEquals(test, expected);
- }
-
- //-----------------------------------------------------------------------
// withHour()
//-----------------------------------------------------------------------
@Test(groups={"tck"})
@@ -835,35 +824,6 @@ public void test_withNanoOfSecond_normal() {
}
//-----------------------------------------------------------------------
- // withTime()
- //-----------------------------------------------------------------------
- @Test(groups={"tck"})
- public void test_withTime_HM() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
- OffsetDateTime test = base.withTime(12, 10);
- OffsetDateTime expected = OffsetDateTime.of(2008, 6, 30, 12, 10, 0, 0, OFFSET_PONE);
- assertEquals(test, expected);
- }
-
- //-----------------------------------------------------------------------
- @Test(groups={"tck"})
- public void test_withTime_HMS() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
- OffsetDateTime test = base.withTime(12, 10, 9);
- OffsetDateTime expected = OffsetDateTime.of(2008, 6, 30, 12, 10, 9, 0, OFFSET_PONE);
- assertEquals(test, expected);
- }
-
- //-----------------------------------------------------------------------
- @Test(groups={"tck"})
- public void test_withTime_HMSN() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, OFFSET_PONE);
- OffsetDateTime test = base.withTime(12, 10, 9, 8);
- OffsetDateTime expected = OffsetDateTime.of(2008, 6, 30, 12, 10, 9, 8, OFFSET_PONE);
- assertEquals(test, expected);
- }
-
- //-----------------------------------------------------------------------
// plus(Period)
//-----------------------------------------------------------------------
@Test(groups={"tck"})
View
28 src/test/java/javax/time/TestOffsetDateTime.java
@@ -254,13 +254,6 @@ public void test_withDayOfYear_noChange() {
}
@Test(groups={"implementation"})
- public void test_withDate_noChange() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, OFFSET_PONE);
- OffsetDateTime test = base.withDate(2008, 6, 30);
- assertSame(test, base);
- }
-
- @Test(groups={"implementation"})
public void test_withHour_noChange() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, OFFSET_PONE);
OffsetDateTime test = base.withHour(11);
@@ -289,27 +282,6 @@ public void test_withNanoOfSecond_noChange() {
}
@Test(groups={"implementation"})
- public void test_withTime_HM_noChange() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, OFFSET_PONE);
- OffsetDateTime test = base.withTime(11, 30);
- assertSame(test, base);
- }
-
- @Test(groups={"implementation"})
- public void test_withTime_HMS_noChange() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, OFFSET_PONE);
- OffsetDateTime test = base.withTime(11, 30, 59);
- assertSame(test, base);
- }
-
- @Test(groups={"implementation"})
- public void test_withTime_HMSN_noChange() {
- OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_PONE);
- OffsetDateTime test = base.withTime(11, 30, 59, 500);
- assertSame(test, base);
- }
-
- @Test(groups={"implementation"})
public void test_plus_Period_zero() {
OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(MockSimplePeriod.ZERO_DAYS);
assertSame(t, TEST_2008_6_30_11_30_59_000000500);
Please sign in to comment.
Something went wrong with that request. Please try again.