Java Code Examples for java.time.zone.ZoneOffsetTransition#of()
The following examples show how to use
java.time.zone.ZoneOffsetTransition#of() .
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: TCKZoneOffsetTransitionRule.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void test_createTransition_floatingWeekBackwards_seventhLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
Example 2
Source File: TCKZoneOffsetTransition.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_isValidOffset_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); assertEquals(test.isValidOffset(OFFSET_0100), false); assertEquals(test.isValidOffset(OFFSET_0200), true); assertEquals(test.isValidOffset(OFFSET_0230), false); assertEquals(test.isValidOffset(OFFSET_0300), true); assertEquals(test.isValidOffset(OFFSET_0400), false); }
Example 3
Source File: TCKZoneOffsetTransition.java From hottub with GNU General Public License v2.0 | 5 votes |
@Test public void test_hashCode_floatingWeek_gap_notEndOfDay() { LocalDateTime ldtA = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition a1 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition a2 = ZoneOffsetTransition.of(ldtA, OFFSET_0200, OFFSET_0300); LocalDateTime ldtB = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition b = ZoneOffsetTransition.of(ldtB, OFFSET_0300, OFFSET_0200); assertEquals(a1.hashCode(), a1.hashCode()); assertEquals(a1.hashCode(), a2.hashCode()); assertEquals(b.hashCode(), b.hashCode()); }
Example 4
Source File: TCKZoneOffsetTransitionRule.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_createTransition_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
Example 5
Source File: TCKZoneOffsetTransitionRule.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void test_createTransition_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
Example 6
Source File: TCKZoneOffsetTransitionRule.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_createTransition_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
Example 7
Source File: TCKZoneOffsetTransitionRule.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_createTransition_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
Example 8
Source File: TCKZoneOffsetTransitionRule.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void test_createTransition_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
Example 9
Source File: TCKZoneOffsetTransition.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void test_isValidOffset_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.isValidOffset(OFFSET_0100), false); assertEquals(test.isValidOffset(OFFSET_0200), false); assertEquals(test.isValidOffset(OFFSET_0230), false); assertEquals(test.isValidOffset(OFFSET_0300), false); assertEquals(test.isValidOffset(OFFSET_0400), false); }
Example 10
Source File: TCKZoneOffsetTransitionSerialization.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_serialization_overlap() throws Exception { LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0); LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0300, OFFSET_0200); assertSerializable(test); }
Example 11
Source File: TCKZoneOffsetTransitionRule.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void test_createTransition_fixedDate() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 20, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
Example 12
Source File: TCKZoneOffsetTransitionSerialization.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test public void test_serialization_unusual2() throws Exception { LocalDateTime ldt = LocalDateTime.of(Year.MIN_VALUE, 1, 1, 12, 1, 3); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, ZoneOffset.of("+02:04:56"), ZoneOffset.of("+10:02:34")); assertSerializable(test); }
Example 13
Source File: TCKZoneOffsetTransition.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Test public void test_toString_gap() { LocalDateTime ldt = LocalDateTime.of(2010, 3, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "Transition[Gap at 2010-03-31T01:00+02:00 to +03:00]"); }
Example 14
Source File: TCKZoneOffsetTransitionSerialization.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test public void test_serialization_unusual1() throws Exception { LocalDateTime ldt = LocalDateTime.of(Year.MAX_VALUE, 12, 31, 1, 31, 53); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, ZoneOffset.of("+02:04:56"), ZoneOffset.of("-10:02:34")); assertSerializable(test); }
Example 15
Source File: TCKZoneRules.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void test_of(){ //used for standard offset ZoneOffset stdOffset1 = ZoneOffset.UTC; ZoneOffset stdOffset2 = ZoneOffset.ofHours(1); LocalDateTime time_of_stdOffsetTransition1 = LocalDateTime.of(2013, 1, 5, 1, 0); ZoneOffsetTransition stdOffsetTransition1 = ZoneOffsetTransition.of(time_of_stdOffsetTransition1, stdOffset1, stdOffset2); List<ZoneOffsetTransition> stdOffsetTransition_list = new ArrayList<ZoneOffsetTransition>(); stdOffsetTransition_list.add(stdOffsetTransition1); //used for wall offset ZoneOffset wallOffset1 = ZoneOffset.ofHours(2); ZoneOffset wallOffset2 = ZoneOffset.ofHours(4); ZoneOffset wallOffset3 = ZoneOffset.ofHours(7); LocalDateTime time_of_wallOffsetTransition1 = LocalDateTime.of(2013, 2, 5, 1, 0); LocalDateTime time_of_wallOffsetTransition2 = LocalDateTime.of(2013, 3, 5, 1, 0); LocalDateTime time_of_wallOffsetTransition3 = LocalDateTime.of(2013, 10, 5, 1, 0); ZoneOffsetTransition wallOffsetTransition1 = ZoneOffsetTransition.of(time_of_wallOffsetTransition1, wallOffset1, wallOffset2); ZoneOffsetTransition wallOffsetTransition2 = ZoneOffsetTransition.of(time_of_wallOffsetTransition2, wallOffset2, wallOffset3); ZoneOffsetTransition wallOffsetTransition3 = ZoneOffsetTransition.of(time_of_wallOffsetTransition3, wallOffset3, wallOffset1); List<ZoneOffsetTransition> wallOffsetTransition_list = new ArrayList<ZoneOffsetTransition>(); wallOffsetTransition_list.add(wallOffsetTransition1); wallOffsetTransition_list.add(wallOffsetTransition2); wallOffsetTransition_list.add(wallOffsetTransition3); //used for ZoneOffsetTransitionRule ZoneOffset ruleOffset = ZoneOffset.ofHours(3); ZoneOffsetTransitionRule.TimeDefinition timeDefinition = ZoneOffsetTransitionRule.TimeDefinition.valueOf("WALL"); ZoneOffsetTransitionRule rule1 = ZoneOffsetTransitionRule.of(Month.FEBRUARY, 2, DayOfWeek.MONDAY, LocalTime.of(1, 0), false, timeDefinition, ZoneOffset.UTC, ZoneOffset.UTC, ruleOffset ); List<ZoneOffsetTransitionRule> rule_list = new ArrayList<ZoneOffsetTransitionRule>(); rule_list.add(rule1); //Begin verification ZoneRules zoneRule = ZoneRules.of(stdOffset1, wallOffset1, stdOffsetTransition_list, wallOffsetTransition_list, rule_list ); OffsetDateTime before_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).minusSeconds(1); OffsetDateTime after_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).plusSeconds(1);; assertEquals(zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant()), stdOffset1); assertEquals(zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant()), stdOffset2); OffsetDateTime before_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition1); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition2); OffsetDateTime before_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition2); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition3); OffsetDateTime before_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant()), wallOffsetTransition3); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant()), rule1.createTransition(2014)); }
Example 16
Source File: TCKZoneRules.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public void test_of(){ //used for standard offset ZoneOffset stdOffset1 = ZoneOffset.UTC; ZoneOffset stdOffset2 = ZoneOffset.ofHours(1); LocalDateTime time_of_stdOffsetTransition1 = LocalDateTime.of(2013, 1, 5, 1, 0); ZoneOffsetTransition stdOffsetTransition1 = ZoneOffsetTransition.of(time_of_stdOffsetTransition1, stdOffset1, stdOffset2); List<ZoneOffsetTransition> stdOffsetTransition_list = new ArrayList<ZoneOffsetTransition>(); stdOffsetTransition_list.add(stdOffsetTransition1); //used for wall offset ZoneOffset wallOffset1 = ZoneOffset.ofHours(2); ZoneOffset wallOffset2 = ZoneOffset.ofHours(4); ZoneOffset wallOffset3 = ZoneOffset.ofHours(7); LocalDateTime time_of_wallOffsetTransition1 = LocalDateTime.of(2013, 2, 5, 1, 0); LocalDateTime time_of_wallOffsetTransition2 = LocalDateTime.of(2013, 3, 5, 1, 0); LocalDateTime time_of_wallOffsetTransition3 = LocalDateTime.of(2013, 10, 5, 1, 0); ZoneOffsetTransition wallOffsetTransition1 = ZoneOffsetTransition.of(time_of_wallOffsetTransition1, wallOffset1, wallOffset2); ZoneOffsetTransition wallOffsetTransition2 = ZoneOffsetTransition.of(time_of_wallOffsetTransition2, wallOffset2, wallOffset3); ZoneOffsetTransition wallOffsetTransition3 = ZoneOffsetTransition.of(time_of_wallOffsetTransition3, wallOffset3, wallOffset1); List<ZoneOffsetTransition> wallOffsetTransition_list = new ArrayList<ZoneOffsetTransition>(); wallOffsetTransition_list.add(wallOffsetTransition1); wallOffsetTransition_list.add(wallOffsetTransition2); wallOffsetTransition_list.add(wallOffsetTransition3); //used for ZoneOffsetTransitionRule ZoneOffset ruleOffset = ZoneOffset.ofHours(3); ZoneOffsetTransitionRule.TimeDefinition timeDefinition = ZoneOffsetTransitionRule.TimeDefinition.valueOf("WALL"); ZoneOffsetTransitionRule rule1 = ZoneOffsetTransitionRule.of(Month.FEBRUARY, 2, DayOfWeek.MONDAY, LocalTime.of(1, 0), false, timeDefinition, ZoneOffset.UTC, ZoneOffset.UTC, ruleOffset ); List<ZoneOffsetTransitionRule> rule_list = new ArrayList<ZoneOffsetTransitionRule>(); rule_list.add(rule1); //Begin verification ZoneRules zoneRule = ZoneRules.of(stdOffset1, wallOffset1, stdOffsetTransition_list, wallOffsetTransition_list, rule_list ); OffsetDateTime before_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).minusSeconds(1); OffsetDateTime after_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).plusSeconds(1);; assertEquals(zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant()), stdOffset1); assertEquals(zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant()), stdOffset2); OffsetDateTime before_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition1); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition2); OffsetDateTime before_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition2); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition3); OffsetDateTime before_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).minusSeconds(1); OffsetDateTime after_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).plusSeconds(1); assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant()), wallOffsetTransition3); assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant()), rule1.createTransition(2014)); }
Example 17
Source File: TCKZoneOffsetTransition.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); assertEquals(test.toString(), "Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]"); }
Example 18
Source File: TCKZoneOffsetTransition.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_factory_nullOffsetAfter() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30), OFFSET_0200, null); }
Example 19
Source File: TCKZoneOffsetTransition.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test public void test_toString_overlap() { LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0); ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200); assertEquals(test.toString(), "Transition[Overlap at 2010-10-31T01:00+03:00 to +02:00]"); }
Example 20
Source File: TCKZoneOffsetTransition.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=IllegalArgumentException.class) public void test_factory_noNanos() { ZoneOffsetTransition.of(LocalDateTime.of(2010, 12, 3, 11, 30, 0, 500), OFFSET_0200, OFFSET_0300); }