Permalink
Browse files

Rename withLockedOffset() to withFixedOffsetZone()

See #148
  • Loading branch information...
1 parent a6e5e05 commit 71462fda681852f932e33205016352ed0d122508 @jodastephen jodastephen committed Dec 2, 2012
Showing with 18 additions and 16 deletions.
  1. +16 −14 src/main/java/javax/time/ZonedDateTime.java
  2. +2 −2 src/tck/java/javax/time/TCKZonedDateTime.java
@@ -631,12 +631,13 @@ public ZonedDateTime withLaterOffsetAtOverlap() {
/**
* Gets the time-zone, such as 'Europe/Paris'.
* <p>
- * This returns the zone ID. This identifies the time-zone rules that
- * determine when and how the offset from UTC/Greenwich changes.
+ * This returns the zone ID. This identifies the time-zone {@link ZoneRules rules}
+ * that determine when and how the offset from UTC/Greenwich changes.
* <p>
- * The zone ID may be {@link #withLockedOffset() locked} to a fixed offset,
- * in which case the result of this method and {@link #getOffset()} will
- * be the same.
+ * The zone ID may be same as the {@link #getOffset() offset}.
+ * If this is true, then any future calculations, such as addition or subtraction,
+ * have no complex edge cases due to time-zone rules.
+ * See also {@link #withFixedOffsetZone()}.
*
* @return the time-zone, not null
*/
@@ -693,23 +694,24 @@ public ZonedDateTime withZoneSameInstant(ZoneId zone) {
}
/**
- * Returns a copy of this date-time with the zone ID locked to the offset.
+ * Returns a copy of this date-time with the zone ID set to the offset.
* <p>
- * This locks the offset of the zoned date-time by returning a date-time that
- * has the zone ID equal to the offset. The local date-time, offset and
+ * This returns a zoned date-time where the zone ID is the same as the current
+ * result of {@link #getOffset()}. The local date-time, offset and
* instant of the result will be the same as in this date-time.
* <p>
- * Locking the date-time to a single offset means that any future calculations,
- * such as addition or subtraction, are guaranteed to work without any complex
- * side effects due to time-zone rules.
+ * Setting the date-time to a fixed single offset means that any future
+ * calculations, such as addition or subtraction, have no complex edge cases
+ * due to time-zone rules.
* This might also be useful when sending a zoned date-time across a network,
- * as most protocols, such as ISO-8601, only handle offsets, and not zone IDs.
+ * as most protocols, such as ISO-8601, only handle offsets,
+ * and not region-based zone IDs.
* <p>
- * This is equivalent to {@code zdt.withOffsetSameInstant(zdt.getOffset())}.
+ * This is equivalent to {@code ZonedDateTime.of(zdt.getDateTime(), zdt.getOffset())}.
*
* @return a {@code ZonedDateTime} with the zone ID set to the offset, not null
*/
- public ZonedDateTime withLockedOffset() {
+ public ZonedDateTime withFixedOffsetZone() {
return this.zone.equals(offset) ? this : new ZonedDateTime(dateTime, offset, offset);
}
@@ -1022,12 +1022,12 @@ public void test_withZoneSameInstant_null() {
}
//-----------------------------------------------------------------------
- // withLockedOffset()
+ // withFixedOffsetZone()
//-----------------------------------------------------------------------
@Test(groups={"tck"})
public void test_withZoneLocked() {
ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS);
- ZonedDateTime test = base.withLockedOffset();
+ ZonedDateTime test = base.withFixedOffsetZone();
ZonedDateTime expected = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0200);
assertEquals(test, expected);
}

0 comments on commit 71462fd

Please sign in to comment.