Java Code Examples for org.threeten.bp.ZoneOffset#ofHours()
The following examples show how to use
org.threeten.bp.ZoneOffset#ofHours() .
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: TestMinguoChronology.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SuppressWarnings("unused") @Test(dataProvider="samples") public void test_MinguoDate(ChronoLocalDate minguoDate, LocalDate iso) { ChronoLocalDate hd = minguoDate; ChronoLocalDateTime<?> hdt = hd.atTime(LocalTime.NOON); ZoneOffset zo = ZoneOffset.ofHours(1); ChronoZonedDateTime<?> hzdt = hdt.atZone(zo); hdt = hdt.plus(1, ChronoUnit.YEARS); hdt = hdt.plus(1, ChronoUnit.MONTHS); hdt = hdt.plus(1, ChronoUnit.DAYS); hdt = hdt.plus(1, ChronoUnit.HOURS); hdt = hdt.plus(1, ChronoUnit.MINUTES); hdt = hdt.plus(1, ChronoUnit.SECONDS); hdt = hdt.plus(1, ChronoUnit.NANOS); ChronoLocalDateTime<?> a2 = hzdt.toLocalDateTime(); ChronoLocalDate a3 = a2.toLocalDate(); ChronoLocalDate a5 = hzdt.toLocalDate(); //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5); }
Example 2
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_twoChangesSameDay() { // ensures that TZRule.compare works ZoneOffset plus2 = ZoneOffset.ofHours(2); ZoneOffset plus3 = ZoneOffset.ofHours(3); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindowForever(plus2); b.addRuleToWindow(2010, 2010, SEPTEMBER, 10, null, time(12, 0), false, STANDARD, PERIOD_1HOUR); b.addRuleToWindow(2010, 2010, SEPTEMBER, 10, null, time(23, 0), false, STANDARD, PERIOD_0); ZoneRules test = b.toRules("Africa/Cairo"); assertOffsetInfo(test, DATE_TIME_FIRST, plus2); assertOffsetInfo(test, DATE_TIME_LAST, plus2); assertGap(test, 2010, 9, 10, 12, 0, plus2, plus3); // jump forward from 12:00 to 13:00 on Tue 10th Sep assertOverlap(test, 2010, 9, 10, 23, 0, plus3, plus2); // overlaps from Wed 11th Sep 00:00 back to Tue 10th Sep 23:00 }
Example 3
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_twoChangesDifferentDefinition() { // ensures that TZRule.compare works ZoneOffset plus2 = ZoneOffset.ofHours(2); ZoneOffset plus3 = ZoneOffset.ofHours(3); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindowForever(plus2); b.addRuleToWindow(2010, 2010, SEPTEMBER, -1, TUESDAY, time(0, 0), false, STANDARD, PERIOD_1HOUR); b.addRuleToWindow(2010, 2010, SEPTEMBER, 29, null, time(23, 0), false, STANDARD, PERIOD_0); ZoneRules test = b.toRules("Africa/Cairo"); assertOffsetInfo(test, DATE_TIME_FIRST, plus2); assertOffsetInfo(test, DATE_TIME_LAST, plus2); assertGap(test, 2010, 9, 28, 0, 0, plus2, plus3); // jump forward from 00:00 to 01:00 on Tue 28th Sep assertOverlap(test, 2010, 9, 29, 23, 0, plus3, plus2); // overlaps from Thu 30th Sep 00:00 back to Wed 29th Sep 23:00 }
Example 4
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_cairo_dateChange() { // Rule Egypt 2008 max - Apr lastFri 0:00s 1:00 S // Rule Egypt 2008 max - Aug lastThu 23:00s 0 - // Zone Africa/Cairo 2:05:00 - LMT 1900 Oct // 2:00 Egypt EE%sT ZoneOffset plus2 = ZoneOffset.ofHours(2); ZoneOffset plus3 = ZoneOffset.ofHours(3); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindowForever(plus2); b.addRuleToWindow(2008, Year.MAX_VALUE, APRIL, -1, FRIDAY, time(0, 0), false, STANDARD, PERIOD_1HOUR); b.addRuleToWindow(2008, Year.MAX_VALUE, AUGUST, -1, THURSDAY, time(23, 0), false, STANDARD, PERIOD_0); ZoneRules test = b.toRules("Africa/Cairo"); assertOffsetInfo(test, DATE_TIME_FIRST, plus2); assertOffsetInfo(test, DATE_TIME_LAST, plus2); assertGap(test, 2009, 4, 24, 0, 0, plus2, plus3); assertOverlap(test, 2009, 8, 27, 23, 0, plus3, plus2); // overlaps from Fri 00:00 back to Thu 23:00 }
Example 5
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_cairo_twoChangesSameMonth() { // 2011i // Rule Egypt 2010 only - Aug 11 0:00 0 - // Rule Egypt 2010 only - Sep 10 0:00 1:00 S // Rule Egypt 2010 only - Sep lastThu 23:00s 0 - // Zone Africa/Cairo 2:05:00 - LMT 1900 Oct // 2:00 Egypt EE%sT ZoneOffset plus2 = ZoneOffset.ofHours(2); ZoneOffset plus3 = ZoneOffset.ofHours(3); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindowForever(plus2); b.addRuleToWindow(2010, 2010, AUGUST, 11, null, time(0, 0), false, STANDARD, PERIOD_0); b.addRuleToWindow(2010, 2010, SEPTEMBER, 10, null, time(0, 0), false, STANDARD, PERIOD_1HOUR); b.addRuleToWindow(2010, 2010, SEPTEMBER, -1, THURSDAY, time(23, 0), false, STANDARD, PERIOD_0); ZoneRules test = b.toRules("Africa/Cairo"); assertOffsetInfo(test, DATE_TIME_FIRST, plus2); assertOffsetInfo(test, DATE_TIME_LAST, plus2); assertGap(test, 2010, 9, 10, 0, 0, plus2, plus3); // jump forward from 00:00 to 01:00 on Fri 10th Sep assertOverlap(test, 2010, 9, 30, 23, 0, plus3, plus2); // overlaps from Fri 1st Oct 00:00 back to Thu 30th Sep 23:00 (!!!) }
Example 6
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void test_jordan2400() { // rule is 24:00 - this is simplified from the TZDB // Rule Jordan 2002 max - Mar lastThu 24:00 1:00 S // Rule Jordan 2002 max - Sep lastFri 0:00s 0 - // # Zone NAME GMTOFF RULES FORMAT [UNTIL] // 2:00 Jordan EE%sT ZoneOffset plus2 = ZoneOffset.ofHours(2); ZoneOffset plus3 = ZoneOffset.ofHours(3); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindowForever(plus2); b.addRuleToWindow(2002, Year.MAX_VALUE, MARCH, -1, THURSDAY, time(0, 0), true, WALL, PERIOD_1HOUR); b.addRuleToWindow(2002, Year.MAX_VALUE, SEPTEMBER, -1, FRIDAY, time(0, 0), false, STANDARD, PERIOD_0); ZoneRules test = b.toRules("Asia/Amman"); assertOffsetInfo(test, DATE_TIME_FIRST, plus2); assertOffsetInfo(test, DATE_TIME_LAST, plus2); assertGap(test, 2002, 3, 29, 0, 0, plus2, plus3); assertOffsetInfo(test, dateTime(2002, 3, 28, 23, 0), plus2); assertOffsetInfo(test, dateTime(2002, 3, 29, 1, 0), plus3); assertOverlap(test, 2002, 9, 27, 0, 0, plus3, plus2); assertOffsetInfo(test, dateTime(2002, 9, 26, 23, 0), plus3); assertOffsetInfo(test, dateTime(2002, 9, 27, 1, 0), plus2); }
Example 7
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void test_prague() { // need to calculate savings applicable at window start based on // first rule being transition from no savings to DST // Rule C-Eur 1944 1945 - Apr Mon>=1 2:00s 1:00 S // Rule C-Eur 1944 only - Oct 2 2:00s 0 - // Rule C-Eur 1945 only - Sep 16 2:00s 0 - // Rule Czech 1945 only - Apr 8 2:00s 1:00 S // Rule Czech 1945 only - Nov 18 2:00s 0 - // Zone Europe/Prague 0:57:44 - LMT 1850 // 0:57:44 - PMT 1891 Oct // 1:00 C-Eur CE%sT 1944 Sep 17 2:00s // 1:00 Czech CE%sT 1979 // 1:00 EU CE%sT ZoneOffset plus1 = ZoneOffset.ofHours(1); ZoneOffset plus2 = ZoneOffset.ofHours(2); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindow(plus1, dateTime(1944, 9, 17, 2, 0), STANDARD); b.addRuleToWindow(1944, 1945, APRIL, 1, MONDAY, time(2, 0), false, STANDARD, PERIOD_1HOUR); b.addRuleToWindow(1944, OCTOBER, 2, time(2, 0), false, STANDARD, PERIOD_0); b.addRuleToWindow(1945, SEPTEMBER, 16, time(2, 0), false, STANDARD, PERIOD_0); b.addWindow(plus1, dateTime(1979, 1, 1, 0, 0), WALL); b.addRuleToWindow(1945, APRIL, 8, time(2, 0), false, STANDARD, PERIOD_1HOUR); b.addRuleToWindow(1945, NOVEMBER, 18, time(2, 0), false, STANDARD, PERIOD_0); b.addWindowForever(plus1); ZoneRules test = b.toRules("Europe/Sofia"); assertOffsetInfo(test, DATE_TIME_FIRST, plus1); assertOffsetInfo(test, DATE_TIME_LAST, plus1); assertGap(test, 1944, 4, 3, 2, 30, plus1, plus2); assertOverlap(test, 1944, 9, 17, 2, 30, plus2, plus1); assertOffsetInfo(test, dateTime(1944, 9, 17, 3, 30), plus1); assertOffsetInfo(test, dateTime(1944, 9, 17, 4, 30), plus1); assertGap(test, 1945, 4, 8, 2, 30, plus1, plus2); assertOverlap(test, 1945, 11, 18, 2, 30, plus2, plus1); }
Example 8
Source File: TestStandardZoneRules.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void test_NewYork_getOffset_fromDST() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-4); assertEquals(test.getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 11, 2, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 11, 3, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 11, 4, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 11, 5, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 11, 6, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 11, 7, offset)), ZoneOffset.ofHours(-5)); // cutover at 02:00 local assertEquals(test.getOffset(createInstant(2008, 11, 2, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 11, 2, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-5)); }
Example 9
Source File: TestStandardZoneRules.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void test_NewYork_getOffset_toDST() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-5); assertEquals(test.getOffset(createInstant(2008, 3, 8, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 3, 9, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 3, 10, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 3, 11, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 3, 12, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 3, 13, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 3, 14, offset)), ZoneOffset.ofHours(-4)); // cutover at 02:00 local assertEquals(test.getOffset(createInstant(2008, 3, 9, 1, 59, 59, 999999999, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 3, 9, 2, 0, 0, 0, offset)), ZoneOffset.ofHours(-4)); }
Example 10
Source File: TestStandardZoneRules.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void test_NewYork_getOffset() { ZoneRules test = americaNewYork(); ZoneOffset offset = ZoneOffset.ofHours(-5); assertEquals(test.getOffset(createInstant(2008, 1, 1, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 2, 1, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 3, 1, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 4, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 5, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 6, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 7, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 8, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 9, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 10, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 11, 1, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 12, 1, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 1, 28, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 2, 28, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 3, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 4, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 5, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 6, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 7, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 8, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 9, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 10, 28, offset)), ZoneOffset.ofHours(-4)); assertEquals(test.getOffset(createInstant(2008, 11, 28, offset)), ZoneOffset.ofHours(-5)); assertEquals(test.getOffset(createInstant(2008, 12, 28, offset)), ZoneOffset.ofHours(-5)); }
Example 11
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void test_japan2500() { // cutover time overflows into next day // Rule Japan 1948 only - May Sat>=1 24:00 1:00 D // Rule Japan 1948 1951 - Sep Sat>=8 25:00 0 S // Rule Japan 1949 only - Apr Sat>=1 24:00 1:00 D // Rule Japan 1950 1951 - May Sat>=1 24:00 1:00 D ZoneOffset plus9 = ZoneOffset.ofHours(9); ZoneOffset plus10 = ZoneOffset.ofHours(10); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindowForever(plus9); b.addRuleToWindow(1948, 1948, MAY, 1, SATURDAY, time(0, 0), true, WALL, PERIOD_1HOUR); b.addRuleToWindow(1948, 1951, SEPTEMBER, 8, SATURDAY, time(1, 0), 1, WALL, PERIOD_0); b.addRuleToWindow(1949, 1949, APRIL, 1, SATURDAY, time(0, 0), true, WALL, PERIOD_1HOUR); b.addRuleToWindow(1950, 1951, MAY, 1, SATURDAY, time(0, 0), true, WALL, PERIOD_1HOUR); ZoneRules test = b.toRules("Japan"); assertOffsetInfo(test, DATE_TIME_FIRST, plus9); assertOffsetInfo(test, DATE_TIME_LAST, plus9); // Sat>=1 => May 1st assertGap(test, 1948, 5, 2, 0, 0, plus9, plus10); assertOffsetInfo(test, dateTime(1948, 5, 1, 23, 0), plus9); assertOffsetInfo(test, dateTime(1948, 5, 2, 1, 0), plus10); // Sat>=8 => September 11th assertOverlap(test, 1948, 9, 12, 0, 0, plus10, plus9); assertOffsetInfo(test, dateTime(1948, 9, 11, 23, 0), plus10); assertOffsetInfo(test, dateTime(1948, 9, 12, 1, 0), plus9); // Sat>=1 => May 2nd assertGap(test, 1949, 4, 3, 0, 0, plus9, plus10); assertOffsetInfo(test, dateTime(1949, 4, 2, 23, 0), plus9); assertOffsetInfo(test, dateTime(1949, 4, 3, 1, 0), plus10); }
Example 12
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void test_iqaluit() { // two hour overlap due to end of daylight and change of standard offset // Rule Canada 1987 2006 - Apr Sun>=1 2:00 1:00 D // Rule Canada 1974 2006 - Oct lastSun 2:00 0 S // Rule NT_YK 1987 2006 - Apr Sun>=1 2:00 1:00 D // Rule NT_YK 1980 2006 - Oct lastSun 2:00 0 S // -5:00 NT_YK E%sT 1999 Oct 31 2:00 // -6:00 Canada C%sT ZoneOffset minus4 = ZoneOffset.ofHours(-4); ZoneOffset minus5 = ZoneOffset.ofHours(-5); ZoneOffset minus6 = ZoneOffset.ofHours(-6); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindow(minus5, dateTime(1999, 10, 31, 2, 0), WALL); b.addRuleToWindow(1987, Year.MAX_VALUE, APRIL, 1, SUNDAY, time(2, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(1987, Year.MAX_VALUE, OCTOBER, -1, SUNDAY, time(2, 0), false, WALL, PERIOD_0); b.addWindowForever(minus6); b.addRuleToWindow(1987, Year.MAX_VALUE, APRIL, 1, SUNDAY, time(2, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(1987, Year.MAX_VALUE, OCTOBER, -1, SUNDAY, time(2, 0), false, WALL, PERIOD_0); ZoneRules test = b.toRules("America/Iqaluit"); assertOffsetInfo(test, DATE_TIME_FIRST, minus5); assertOffsetInfo(test, DATE_TIME_LAST, minus6); assertOffsetInfo(test, dateTime(1999, 10, 30, 23, 0), minus4); assertOverlap(test, 1999, 10, 31, 0, 0, minus4, minus6); assertOverlap(test, 1999, 10, 31, 1, 0, minus4, minus6); assertOverlap(test, 1999, 10, 31, 1, 59, minus4, minus6); assertOffsetInfo(test, dateTime(1999, 10, 31, 2, 0), minus6); assertOffsetInfo(test, dateTime(1999, 10, 31, 3, 0), minus6); }
Example 13
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void test_vincennes() { // need to ensure that at least one real rule is added to expand on the last rule // Rule US 2007 max - Mar Sun>=8 2:00 1:00 D // Rule US 2007 max - Nov Sun>=1 2:00 0 S // -5:00 - EST 2006 Apr 2 2:00 // -6:00 US C%sT 2007 Nov 4 2:00 // -5:00 US E%sT ZoneOffset minus5 = ZoneOffset.ofHours(-5); ZoneOffset minus6 = ZoneOffset.ofHours(-6); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindow(minus6, dateTime(2007, 11, 4, 2, 0), WALL); b.addRuleToWindow(2007, Year.MAX_VALUE, MARCH, 8, SUNDAY, time(2, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(2007, Year.MAX_VALUE, NOVEMBER, 1, SUNDAY, time(2, 0), false, WALL, PERIOD_0); b.addWindowForever(minus5); b.addRuleToWindow(2007, Year.MAX_VALUE, MARCH, 8, SUNDAY, time(2, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(2007, Year.MAX_VALUE, NOVEMBER, 1, SUNDAY, time(2, 0), false, WALL, PERIOD_0); ZoneRules test = b.toRules("America/Indiana/Vincennes"); assertOffsetInfo(test, DATE_TIME_FIRST, minus6); assertOffsetInfo(test, DATE_TIME_LAST, minus5); assertOffsetInfo(test, dateTime(2007, 3, 11, 0, 0), minus6); assertOffsetInfo(test, dateTime(2007, 3, 11, 1, 0), minus6); assertGap(test, 2007, 3, 11, 2, 0, minus6, minus5); assertOffsetInfo(test, dateTime(2007, 3, 11, 3, 0), minus5); assertOffsetInfo(test, dateTime(2007, 3, 11, 4, 0), minus5); assertOffsetInfo(test, dateTime(2007, 3, 11, 5, 0), minus5); }
Example 14
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void test_sofia_lastRuleClash() { // UTC rule change in 1996 occurs after Wall change // need to ensure that last rule is only applied to last window // Rule E-Eur 1981 max - Mar lastSun 0:00 1:00 S // Rule E-Eur 1996 max - Oct lastSun 0:00 0 - // Rule EU 1981 max - Mar lastSun 1:00u 1:00 S // Rule EU 1996 max - Oct lastSun 1:00u 0 - // Zone Europe/Sofia // 2:00 E-Eur EE%sT 1997 // 2:00 EU EE%sT ZoneOffset plus2 = ZoneOffset.ofHours(2); ZoneOffset plus3 = ZoneOffset.ofHours(3); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindow(plus2, dateTime(1997, 1, 1, 0, 0), WALL); b.addRuleToWindow(1996, Year.MAX_VALUE, MARCH, -1, SUNDAY, time(1, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(1996, Year.MAX_VALUE, OCTOBER, -1, SUNDAY, time(1, 0), false, WALL, PERIOD_0); b.addWindowForever(plus2); b.addRuleToWindow(1996, Year.MAX_VALUE, MARCH, -1, SUNDAY, time(1, 0), false, UTC, PERIOD_1HOUR); b.addRuleToWindow(1996, Year.MAX_VALUE, OCTOBER, -1, SUNDAY, time(1, 0), false, UTC, PERIOD_0); ZoneRules test = b.toRules("Europe/Sofia"); assertOffsetInfo(test, DATE_TIME_FIRST, plus2); assertOffsetInfo(test, DATE_TIME_LAST, plus2); assertGap(test, 1996, 3, 31, 1, 0, plus2, plus3); assertOverlap(test, 1996, 10, 27, 0, 0, plus3, plus2); assertOffsetInfo(test, dateTime(1996, 10, 27, 1, 0), plus2); assertOffsetInfo(test, dateTime(1996, 10, 27, 2, 0), plus2); assertOffsetInfo(test, dateTime(1996, 10, 27, 3, 0), plus2); assertOffsetInfo(test, dateTime(1996, 10, 27, 4, 0), plus2); }
Example 15
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void test_tbilisi() { // has transition into and out of 1 year of permanent DST (Mar96-Oct97) // where the date in the window and rule are the same // this is weird because the wall time in the rule is amended by the actual // wall time from the zone lines // Rule E-EurAsia 1981 max - Mar lastSun 0:00 1:00 S // Rule E-EurAsia 1979 1995 - Sep lastSun 0:00 0 - // Rule E-EurAsia 1996 max - Oct lastSun 0:00 0 - // Zone Asia/Tbilisi 2:59:16 - LMT 1880 // 4:00 E-EurAsia GE%sT 1996 Oct lastSun // 4:00 1:00 GEST 1997 Mar lastSun // 4:00 E-EurAsia GE%sT 2004 Jun 27 // 3:00 RussiaAsia GE%sT 2005 Mar lastSun 2:00 // 4:00 - GET ZoneOffset plus4 = ZoneOffset.ofHours(4); ZoneOffset plus5 = ZoneOffset.ofHours(5); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindow(plus4, dateTime(1996, 10, 27, 0, 0), WALL); b.addRuleToWindow(1996, Year.MAX_VALUE, MARCH, -1, SUNDAY, time(0, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(1996, Year.MAX_VALUE, OCTOBER, -1, SUNDAY, time(0, 0), false, WALL, PERIOD_0); b.addWindow(plus4, dateTime(1997, 3, 30, 0, 0), WALL); b.setFixedSavingsToWindow(PERIOD_1HOUR); b.addWindowForever(plus4); b.addRuleToWindow(1996, Year.MAX_VALUE, MARCH, -1, SUNDAY, time(0, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(1996, Year.MAX_VALUE, OCTOBER, -1, SUNDAY, time(0, 0), false, WALL, PERIOD_0); ZoneRules test = b.toRules("Europe/Sofia"); assertOffsetInfo(test, DATE_TIME_FIRST, plus4); assertOffsetInfo(test, DATE_TIME_LAST, plus4); assertGap(test, 1996, 3, 31, 0, 30, plus4, plus5); // assertOverlap(test, 1996, 10, 26, 23, 30, plus5, plus4); // fixed DST blocks overlap assertOffsetInfo(test, dateTime(1996, 10, 26, 22, 30), plus5); assertOffsetInfo(test, dateTime(1996, 10, 26, 23, 30), plus5); assertOffsetInfo(test, dateTime(1996, 10, 27, 0, 30), plus5); // assertOverlap(test, 1997, 3, 30, 0, 30, plus5, plus4); // end of fixed blocks overlap assertOffsetInfo(test, dateTime(1997, 3, 29, 22, 30), plus5); assertOffsetInfo(test, dateTime(1997, 3, 29, 23, 30), plus5); assertOffsetInfo(test, dateTime(1997, 3, 30, 0, 30), plus5); assertOffsetInfo(test, dateTime(1997, 3, 30, 1, 30), plus5); assertOffsetInfo(test, dateTime(1997, 3, 30, 2, 30), plus5); assertOverlap(test, 1997, 10, 25, 23, 30, plus5, plus4); }
Example 16
Source File: TestZoneOffsetParser.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "+00", ZoneOffset.UTC}, {"+HH", "-00", ZoneOffset.UTC}, {"+HH", "+01", ZoneOffset.ofHours(1)}, {"+HH", "-01", ZoneOffset.ofHours(-1)}, {"+HHMM", "+0000", ZoneOffset.UTC}, {"+HHMM", "-0000", ZoneOffset.UTC}, {"+HHMM", "+0102", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HHMM", "-0102", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HH:MM", "+00:00", ZoneOffset.UTC}, {"+HH:MM", "-00:00", ZoneOffset.UTC}, {"+HH:MM", "+01:02", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HH:MM", "-01:02", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HHMMss", "+0000", ZoneOffset.UTC}, {"+HHMMss", "-0000", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+0159", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "+010215", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMss", "+000000", ZoneOffset.UTC}, {"+HHMMss", "-000000", ZoneOffset.UTC}, {"+HHMMss", "+010000", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMss", "+015959", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HHMMss", "+020000", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+180000", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "-010000", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-020000", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-180000", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "+00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "-00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:ss", "+01:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "+01:02:15", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "+00:00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "-00:00:00", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:ss", "+01:59:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HH:MM:ss", "+02:00:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "-01:00:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMSS", "+000000", ZoneOffset.UTC}, {"+HHMMSS", "-000000", ZoneOffset.UTC}, {"+HHMMSS", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMSS", "-010203", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HH:MM:SS", "+00:00:00", ZoneOffset.UTC}, {"+HH:MM:SS", "-00:00:00", ZoneOffset.UTC}, {"+HH:MM:SS", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:SS", "-01:02:03", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, }; }
Example 17
Source File: TestZoneRulesBuilder.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void test_argentina() { // # On October 3, 1999, 0:00 local, Argentina implemented daylight savings time, // # which did not result in the switch of a time zone, as they stayed 9 hours // # from the International Date Line. // Rule Arg 1989 1993 - Mar Sun>=1 0:00 0 - // Rule Arg 1989 1992 - Oct Sun>=15 0:00 1:00 S // Rule Arg 1999 only - Oct Sun>=1 0:00 1:00 S // Rule Arg 2000 only - Mar 3 0:00 0 - // Zone America/Argentina/Tucuman -4:20:52 - LMT 1894 Oct 31 // -3:00 Arg AR%sT 1999 Oct 3 // -4:00 Arg AR%sT 2000 Mar 3 ZoneOffset minus3 = ZoneOffset.ofHours(-3); ZoneOffset minus4 = ZoneOffset.ofHours(-4); ZoneRulesBuilder b = new ZoneRulesBuilder(); b.addWindow(minus3, dateTime(1900, 1, 1, 0, 0), WALL); b.addWindow(minus3, dateTime(1999, 10, 3, 0, 0), WALL); b.addRuleToWindow(1993, MARCH, 3, time(0, 0), false, WALL, PERIOD_0); b.addRuleToWindow(1999, OCTOBER, 3, time(0, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(2000, MARCH, 3, time(0, 0), false, WALL, PERIOD_0); b.addWindow(minus4, dateTime(2000, 3, 3, 0, 0), WALL); b.addRuleToWindow(1993, MARCH, 3, time(0, 0), false, WALL, PERIOD_0); b.addRuleToWindow(1999, OCTOBER, 3, time(0, 0), false, WALL, PERIOD_1HOUR); b.addRuleToWindow(2000, MARCH, 3, time(0, 0), false, WALL, PERIOD_0); b.addWindowForever(minus3); ZoneRules test = b.toRules("America/Argentina/Tucuman"); assertOffsetInfo(test, DATE_TIME_FIRST, minus3); assertOffsetInfo(test, DATE_TIME_LAST, minus3); assertOffsetInfo(test, dateTime(1999, 10, 2, 22, 59), minus3); assertOffsetInfo(test, dateTime(1999, 10, 2, 23, 59), minus3); assertOffsetInfo(test, dateTime(1999, 10, 3, 0, 0), minus3); assertOffsetInfo(test, dateTime(1999, 10, 3, 1, 0), minus3); assertOffsetInfo(test, dateTime(2000, 3, 2, 22, 59), minus3); assertOffsetInfo(test, dateTime(2000, 3, 2, 23, 59), minus3); assertOffsetInfo(test, dateTime(2000, 3, 3, 0, 0), minus3); assertOffsetInfo(test, dateTime(2000, 3, 3, 1, 0), minus3); }
Example 18
Source File: TestZoneOffsetPrinter.java From threetenbp with BSD 3-Clause "New" or "Revised" License | 4 votes |
@DataProvider(name="offsets") Object[][] provider_offsets() { return new Object[][] { {"+HH", "NO-OFFSET", ZoneOffset.UTC}, {"+HH", "+01", ZoneOffset.ofHours(1)}, {"+HH", "-01", ZoneOffset.ofHours(-1)}, {"+HHMM", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMM", "+0102", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HHMM", "-0102", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HH:MM", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM", "+01:02", ZoneOffset.ofHoursMinutes(1, 2)}, {"+HH:MM", "-01:02", ZoneOffset.ofHoursMinutes(-1, -2)}, {"+HHMMss", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+0102", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HHMMss", "+0159", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "+010215", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMss", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMss", "+0100", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HHMMss", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMss", "+015959", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HHMMss", "+0200", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HHMMss", "+1800", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HHMMss", "-0100", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HHMMss", "-0200", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HHMMss", "-1800", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:ss", "+01:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 0)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "+01:02:15", ZoneOffset.ofHoursMinutesSeconds(1, 2, 15)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HH:MM:ss", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:ss", "+01:00", ZoneOffset.ofHoursMinutesSeconds(1, 0, 0)}, {"+HH:MM:ss", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:ss", "+01:59:59", ZoneOffset.ofHoursMinutesSeconds(1, 59, 59)}, {"+HH:MM:ss", "+02:00", ZoneOffset.ofHoursMinutesSeconds(2, 0, 0)}, {"+HH:MM:ss", "+18:00", ZoneOffset.ofHoursMinutesSeconds(18, 0, 0)}, {"+HH:MM:ss", "-01:00", ZoneOffset.ofHoursMinutesSeconds(-1, 0, 0)}, {"+HH:MM:ss", "-02:00", ZoneOffset.ofHoursMinutesSeconds(-2, 0, 0)}, {"+HH:MM:ss", "-18:00", ZoneOffset.ofHoursMinutesSeconds(-18, 0, 0)}, {"+HHMMSS", "NO-OFFSET", ZoneOffset.UTC}, {"+HHMMSS", "+010203", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HHMMSS", "-010203", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HHMMSS", "+010200", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HHMMSS", "-010200", ZoneOffset.ofHoursMinutesSeconds(-1, -2, 0)}, {"+HH:MM:SS", "NO-OFFSET", ZoneOffset.UTC}, {"+HH:MM:SS", "+01:02:03", ZoneOffset.ofHoursMinutesSeconds(1, 2, 3)}, {"+HH:MM:SS", "-01:02:03", ZoneOffset.ofHoursMinutesSeconds(-1, -2, -3)}, {"+HH:MM:SS", "+01:02:00", ZoneOffset.ofHoursMinutesSeconds(1, 2, 0)}, {"+HH:MM:SS", "-01:02:00", ZoneOffset.ofHoursMinutesSeconds(-1, -2, 0)}, }; }