Package org.threeten.bp

Examples of org.threeten.bp.ZonedDateTime


        assertEquals(test.isFixedOffset(), false);
    }

    public void test_London_preTimeZones() {
        ZoneRules test = europeLondon();
        ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC);
        Instant instant = old.toInstant();
        ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, -1, -15);
        assertEquals(test.getOffset(instant), offset);
        checkOffset(test, old.toLocalDateTime(), offset, 1);
        assertEquals(test.getStandardOffset(instant), offset);
        assertEquals(test.getDaylightSavings(instant), Duration.ZERO);
        assertEquals(test.isDaylightSavings(instant), false);
    }
View Full Code Here


        assertEquals(trans.hashCode(), otherTrans.hashCode());
    }

    public void test_London_getStandardOffset() {
        ZoneRules test = europeLondon();
        ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
        while (zdt.getYear() < 2010) {
            Instant instant = zdt.toInstant();
            if (zdt.getYear() < 1848) {
                assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15));
            } else if (zdt.getYear() >= 1969 && zdt.getYear() < 1972) {
                assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
            } else {
                assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
            }
            zdt = zdt.plusMonths(6);
        }
    }
View Full Code Here

        ZoneOffsetTransition last = trans.get(trans.size() - 1);
        assertEquals(test.previousTransition(last.getInstant().plusSeconds(1)), last);
        assertEquals(test.previousTransition(last.getInstant().plusNanos(1)), last);

        // Jan 1st of year between transitions and rules
        ZonedDateTime odt = ZonedDateTime.ofInstant(last.getInstant(), last.getOffsetAfter());
        odt = odt.withDayOfYear(1).plusYears(1).with(LocalTime.MIDNIGHT);
        assertEquals(test.previousTransition(odt.toInstant()), last);

        // later years
        for (int year = 1998; year < 2010; year++) {
            ZoneOffsetTransition a = rules.get(0).createTransition(year);
            ZoneOffsetTransition b = rules.get(1).createTransition(year);
View Full Code Here

        assertEquals(test.isFixedOffset(), false);
    }

    public void test_Paris_preTimeZones() {
        ZoneRules test = europeParis();
        ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC);
        Instant instant = old.toInstant();
        ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, 9, 21);
        assertEquals(test.getOffset(instant), offset);
        checkOffset(test, old.toLocalDateTime(), offset, 1);
        assertEquals(test.getStandardOffset(instant), offset);
        assertEquals(test.getDaylightSavings(instant), Duration.ZERO);
        assertEquals(test.isDaylightSavings(instant), false);
    }
View Full Code Here

        assertEquals(trans.hashCode(), otherTrans.hashCode());
    }

    public void test_Paris_getStandardOffset() {
        ZoneRules test = europeParis();
        ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
        while (zdt.getYear() < 2010) {
            Instant instant = zdt.toInstant();
            if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) {
                assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21));
            } else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) {
                assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
            } else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) {
                assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
            } else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) {
                assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
            } else {
                assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
            }
            zdt = zdt.plusMonths(6);
        }
    }
View Full Code Here

        assertEquals(test.isFixedOffset(), false);
    }

    public void test_NewYork_preTimeZones() {
        ZoneRules test = americaNewYork();
        ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC);
        Instant instant = old.toInstant();
        ZoneOffset offset = ZoneOffset.of("-04:56:02");
        assertEquals(test.getOffset(instant), offset);
        checkOffset(test, old.toLocalDateTime(), offset, 1);
        assertEquals(test.getStandardOffset(instant), offset);
        assertEquals(test.getDaylightSavings(instant), Duration.ZERO);
        assertEquals(test.isDaylightSavings(instant), false);
    }
View Full Code Here

        assertEquals(trans.hashCode(), otherTrans.hashCode());
    }

    public void test_NewYork_getStandardOffset() {
        ZoneRules test = americaNewYork();
        ZonedDateTime dateTime = createZDT(1860, 1, 1, ZoneOffset.UTC);
        while (dateTime.getYear() < 2010) {
            Instant instant = dateTime.toInstant();
            if (dateTime.toLocalDate().isBefore(LocalDate.of(1883, 11, 18))) {
                assertEquals(test.getStandardOffset(instant), ZoneOffset.of("-04:56:02"));
            } else {
                assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHours(-5));
            }
            dateTime = dateTime.plusMonths(6);
        }
    }
View Full Code Here

    protected StringBuilder buf;

    @BeforeMethod
    public void setUp() {
        printEmptyContext = new DateTimePrintContext(EMPTY, Locale.ENGLISH, DecimalStyle.STANDARD);
        ZonedDateTime zdt = LocalDateTime.of(2011, 6, 30, 12, 30, 40, 0).atZone(ZoneId.of("Europe/Paris"));
        printContext = new DateTimePrintContext(zdt, Locale.ENGLISH, DecimalStyle.STANDARD);
        parseContext = new DateTimeParseContext(Locale.ENGLISH, DecimalStyle.STANDARD, IsoChronology.INSTANCE);
        buf = new StringBuilder();
    }
View Full Code Here

    //-----------------------------------------------------------------------
    // Test Serialization of ISO via chrono API
    //-----------------------------------------------------------------------
    @Test( dataProvider="calendars")
    public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception {
        ZonedDateTime ref = LocalDate.of(2000, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23"));
        ChronoZonedDateTime<?> orginal = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(baos);
        out.writeObject(orginal);
        out.close();
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
View Full Code Here

  @Override
  public FRASecurity createSecurity(final OperationContext context, FRASecurityBean bean) {
    Currency currency = currencyBeanToCurrency(bean.getCurrency());
    ExternalId regionId = externalIdBeanToExternalId(bean.getRegion());
    ZonedDateTime startDate = zonedDateTimeBeanToDateTimeWithZone(bean.getStartDate());
    ZonedDateTime endDate = zonedDateTimeBeanToDateTimeWithZone(bean.getEndDate());
    double rate = bean.getRate();
    double amount = bean.getAmount();
    ExternalId underlyingId = externalIdBeanToExternalId(bean.getUnderlying());
    ZonedDateTime fixingDate = zonedDateTimeBeanToDateTimeWithZone(bean.getFixingDate());
    return new FRASecurity(currency, regionId, startDate, endDate, rate, amount, underlyingId, fixingDate);
  }
View Full Code Here

TOP

Related Classes of org.threeten.bp.ZonedDateTime

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.