Java Code Examples for java.time.ZonedDateTime#with()
The following examples show how to use
java.time.ZonedDateTime#with() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKZonedDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetDateTime_validOffsetNotInOverlap() { // ODT will be a valid ZDT for the zone, so must be retained exactly OffsetDateTime odt = TEST_LOCAL_2008_06_30_11_30_59_500.atOffset(OFFSET_0200); ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(odt); assertEquals(test.toOffsetDateTime(), odt); }
Example 2
Source File: TCKZonedDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetTime_invalidOffsetIgnored1() { // OT has invalid offset for ZDT, so only LT is set OffsetTime ot = OffsetTime.of(0, 50, 30, 40, OFFSET_0130); ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS); // earlier part of overlap ZonedDateTime test = zdt.with(ot); assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 0, 50, 30, 40)); assertEquals(test.getOffset(), OFFSET_0200); // offset not adjusted }
Example 3
Source File: TCKZonedDateTime.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap2() { // ODT will be a valid ZDT for the zone, so must be retained exactly OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0200); ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(odt); assertEquals(test.toOffsetDateTime(), odt); }
Example 4
Source File: TCKZonedDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap2() { // ODT will be a valid ZDT for the zone, so must be retained exactly OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0200); ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(odt); assertEquals(test.toOffsetDateTime(), odt); }
Example 5
Source File: TCKZonedDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_Year() { LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0); ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100); ZonedDateTime test = base.with(Year.of(2007)); assertEquals(test, ZonedDateTime.of(ldt.withYear(2007), ZONE_0100)); }
Example 6
Source File: TCKZonedDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetTime_validOffsetNotInOverlap() { // OT has valid offset for resulting time OffsetTime ot = OffsetTime.of(15, 50, 30, 40, OFFSET_0100); ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(ot); assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 15, 50, 30, 40)); assertEquals(test.getOffset(), OFFSET_0100); }
Example 7
Source File: TCKZonedDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1() { // ODT will be a valid ZDT for the zone, so must be retained exactly OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0100); ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(odt); assertEquals(test.toOffsetDateTime(), odt); }
Example 8
Source File: TCKZonedDateTime.java From j2objc with Apache License 2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1() { // ODT will be a valid ZDT for the zone, so must be retained exactly OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0100); ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(odt); assertEquals(test.toOffsetDateTime(), odt); }
Example 9
Source File: TCKZonedDateTime.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_LocalDate_retainOffset2() { ZoneId newYork = ZoneId.of("America/New_York"); LocalDateTime ldt = LocalDateTime.of(2008, 11, 3, 1, 30); ZonedDateTime base = ZonedDateTime.of(ldt, newYork); assertEquals(base.getOffset(), ZoneOffset.ofHours(-5)); ZonedDateTime test = base.with(LocalDate.of(2008, 11, 2)); assertEquals(test.getOffset(), ZoneOffset.ofHours(-5)); }
Example 10
Source File: TCKZonedDateTime.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1() { // ODT will be a valid ZDT for the zone, so must be retained exactly OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0100); ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(odt); assertEquals(test.toOffsetDateTime(), odt); }
Example 11
Source File: TCKZonedDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap1() { // OT has valid offset for resulting time OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0100); // valid offset in overlap ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); // just before overlap ZonedDateTime test = zdt.with(ot); assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40)); assertEquals(test.getOffset(), OFFSET_0100); }
Example 12
Source File: TCKZonedDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1() { // ODT will be a valid ZDT for the zone, so must be retained exactly OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0100); ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS); ZonedDateTime test = zdt.with(odt); assertEquals(test.toOffsetDateTime(), odt); }
Example 13
Source File: Calendar.java From calendar-component with Apache License 2.0 | 5 votes |
/** * Finds the first day of the week and returns a day representing the start * of that day * * @param start * The actual date * @param expandToFullWeek * Should the returned date be moved to the start of the week * @return If expandToFullWeek is set then it returns the first day of the * week, else it returns a clone of the actual date with the time * set to the start of the day */ protected ZonedDateTime expandStartDate(ZonedDateTime start, boolean expandToFullWeek) { if (expandToFullWeek) { start = getFirstDayOfWeek(start); } else { start = getDayByLocale(start); } // Always expand to the start of the first day to the end of the last day return start.with(LocalTime.MIN); }
Example 14
Source File: TCKZonedDateTime.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_with_adjuster_LocalDate_retainOffset1() { ZoneId newYork = ZoneId.of("America/New_York"); LocalDateTime ldt = LocalDateTime.of(2008, 11, 1, 1, 30); ZonedDateTime base = ZonedDateTime.of(ldt, newYork); assertEquals(base.getOffset(), ZoneOffset.ofHours(-4)); ZonedDateTime test = base.with(LocalDate.of(2008, 11, 2)); assertEquals(test.getOffset(), ZoneOffset.ofHours(-4)); }
Example 15
Source File: TCKZonedDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_with_adjuster_LocalDateTime_adjustedOffset() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDateTime.of(2012, 1, 15, 14, 30)); check(test, 2012, 1, 15, 14, 30, 0, 0, OFFSET_0100, ZONE_PARIS); }
Example 16
Source File: TCKZonedDateTime.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test public void test_withMonth_Month_normal() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100); ZonedDateTime test = base.with(JANUARY); assertEquals(test, ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.withMonth(1), ZONE_0100)); }
Example 17
Source File: TCKZonedDateTime.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test public void test_with_adjuster_Offset_same() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(ZoneOffset.ofHours(2)); check(test, 2012, 7, 31, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); }
Example 18
Source File: TCKZonedDateTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test public void test_with_adjuster_Offset_same() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(ZoneOffset.ofHours(2)); check(test, 2012, 7, 31, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); }
Example 19
Source File: TCKZonedDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test public void test_with_adjuster_Month_adjustedDayOfMonth() { ZonedDateTime base = ZonedDateTime.of(LocalDateTime.of(2012, 7, 31, 0, 0), ZONE_PARIS); ZonedDateTime test = base.with(Month.JUNE); check(test, 2012, 6, 30, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS); }
Example 20
Source File: TCKZonedDateTime.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_with_adjuster_LocalDateTime_adjustedOffset() { ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_PARIS); ZonedDateTime test = base.with(LocalDateTime.of(2012, 1, 15, 14, 30)); check(test, 2012, 1, 15, 14, 30, 0, 0, OFFSET_0100, ZONE_PARIS); }