Java Code Examples for java.time.zone.ZoneRules#of()
The following examples show how to use
java.time.zone.ZoneRules#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: 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 2
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 3
Source File: TCKZoneRules.java From hottub 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 4
Source File: TCKZoneRules.java From openjdk-jdk9 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 5
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 6
Source File: TCKZoneRules.java From openjdk-jdk8u 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 7
Source File: TCKZoneRules.java From openjdk-jdk8u-backup 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 8
Source File: ZoneOffset.java From hottub with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 9
Source File: ZoneOffset.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 10
Source File: ZoneOffset.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 11
Source File: ZoneOffset.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 12
Source File: ZoneOffset.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 13
Source File: ZoneOffset.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 14
Source File: ZoneOffset.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 15
Source File: ZoneOffset.java From j2objc with Apache License 2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 16
Source File: ZoneOffset.java From jdk8u-jdk with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 17
Source File: ZoneOffset.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 18
Source File: ZoneOffset.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 19
Source File: ZoneOffset.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }
Example 20
Source File: ZoneOffset.java From dragonwell8_jdk with GNU General Public License v2.0 | 2 votes |
/** * Gets the associated time-zone rules. * <p> * The rules will always return this offset when queried. * The implementation class is immutable, thread-safe and serializable. * * @return the rules, not null */ @Override public ZoneRules getRules() { return ZoneRules.of(this); }