Examples of DateTimeZone


Examples of org.joda.time.DateTimeZone

    }
   
    public void testDeserializeDefaultDateTime() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeLocalDateTime(null));
        DateTime time = JodaConvert.deserializeLocalDateTime("2008-02-28T01:02:03Z");
        DateTimeZone zone = time.getZone();
        assertEquals(OFFSET_MILLIS, zone.getOffset(time));
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        if (OFFSET_HOURS < -1) {
            assertEquals("Wrong value", 27, time.getDayOfMonth());
            assertEquals("Wrong value", 25+OFFSET_HOURS, time.getHourOfDay());
View Full Code Here

Examples of org.joda.time.DateTimeZone

    }
   
    public void testDeserializeStrictUTCDateTime() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeStrictUTCDateTime(null));
        DateTime time = JodaConvert.deserializeStrictUTCDateTime("2008-02-28T01:02:03Z");
        DateTimeZone zone = time.getZone();
        assertEquals("UTC timezone expected", "UTC", zone.getID());
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        assertEquals("Wrong value", 28, time.getDayOfMonth());
        assertEquals("Wrong value", 1, time.getHourOfDay());
        assertEquals("Wrong value", 2, time.getMinuteOfHour());
View Full Code Here

Examples of org.joda.time.DateTimeZone

    }
   
    public void testDeserializeStrictDefaultDateTime() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeStrictLocalDateTime(null));
        DateTime time = JodaConvert.deserializeStrictLocalDateTime("2008-02-28T01:02:03Z");
        DateTimeZone zone = time.getZone();
        assertEquals(OFFSET_MILLIS, zone.getOffset(time));
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        if (OFFSET_HOURS < -1) {
            assertEquals("Wrong value", 27, time.getDayOfMonth());
            assertEquals("Wrong value", 25+OFFSET_HOURS, time.getHourOfDay());
View Full Code Here

Examples of org.joda.time.DateTimeZone

        IRubyObject tz = h.op_aref(runtime.getCurrentContext(), tzVar);
        if (tz == null || ! (tz instanceof RubyString)) {
            return DateTimeZone.getDefault();
        } else {
            String zone = tz.toString();
            DateTimeZone cachedZone = runtime.getLocalTimezoneCache().get(zone);

            if (cachedZone != null) return cachedZone;

            String originalZone = zone;

            // Value of "TZ" property is of a bit different format,
            // which confuses the Java's TimeZone.getTimeZone(id) method,
            // and so, we need to convert it.

            Matcher tzMatcher = TZ_PATTERN.matcher(zone);
            if (tzMatcher.matches()) {                   
                String sign = tzMatcher.group(2);
                String hours = tzMatcher.group(3);
                String minutes = tzMatcher.group(4);
               
                // GMT+00:00 --> Etc/GMT, see "MRI behavior"
                // comment below.
                if (("00".equals(hours) || "0".equals(hours))
                        && (minutes == null || ":00".equals(minutes) || ":0".equals(minutes))) {
                    zone = "Etc/GMT";
                } else {
                    // Invert the sign, since TZ format and Java format
                    // use opposite signs, sigh... Also, Java API requires
                    // the sign to be always present, be it "+" or "-".
                    sign = ("-".equals(sign)? "+" : "-");

                    // Always use "GMT" since that's required by Java API.
                    zone = "GMT" + sign + hours;

                    if (minutes != null) {
                        zone += minutes;
                    }
                }
            }

            // MRI behavior: With TZ equal to "GMT" or "UTC", Time.now
            // is *NOT* considered as a proper GMT/UTC time:
            //   ENV['TZ']="GMT"
            //   Time.now.gmt? ==> false
            //   ENV['TZ']="UTC"
            //   Time.now.utc? ==> false
            // Hence, we need to adjust for that.
            if ("GMT".equalsIgnoreCase(zone) || "UTC".equalsIgnoreCase(zone)) {
                zone = "Etc/" + zone;
            }

            DateTimeZone dtz = DateTimeZone.forTimeZone(TimeZone.getTimeZone(zone));
            runtime.getLocalTimezoneCache().put(originalZone, dtz);
            return dtz;
        }
    }
View Full Code Here

Examples of org.joda.time.DateTimeZone

            year += 2000;
        } else if (69 <= year && year < 139) {
            year += 1900;
        }

        DateTimeZone dtz;
        if (gmt) {
            dtz = DateTimeZone.UTC;
        } else {
            dtz = getLocalTimeZone(runtime);
        }
View Full Code Here

Examples of org.joda.time.DateTimeZone

        assertEquals(true, julianUTC.hours().isPrecise());
        assertEquals(true, julianUTC.minutes().isPrecise());
        assertEquals(true, julianUTC.seconds().isPrecise());
        assertEquals(true, julianUTC.millis().isPrecise());
       
        final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
        final JulianChronology julianGMT = JulianChronology.getInstance(gmt);
        assertEquals(false, julianGMT.centuries().isPrecise());
        assertEquals(false, julianGMT.years().isPrecise());
        assertEquals(false, julianGMT.weekyears().isPrecise());
        assertEquals(false, julianGMT.months().isPrecise());
View Full Code Here

Examples of org.joda.time.DateTimeZone

        DateTime post = new DateTime(CUTOVER_TURK + 1L, MOCK_TURK);
        assertEquals("2007-04-01T01:00:00.001-04:00", post.toString());
    }

    public void test_lenientChrononolgy_Chicago() {
        DateTimeZone zone = DateTimeZone.forID("America/Chicago");
        Chronology lenient = LenientChronology.getInstance(ISOChronology.getInstance(zone));
        DateTime dt = new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
        assertEquals("2007-03-11T03:30:00.000-05:00", dt.toString());
    }
View Full Code Here

Examples of org.joda.time.DateTimeZone

        DateTime dt = new DateTime(2007, 4, 1, 0, 30, 0, 0, lenient);
        assertEquals("2007-04-01T01:30:00.000-04:00", dt.toString());
    }

    public void test_strictChrononolgy_Chicago() {
        DateTimeZone zone = DateTimeZone.forID("America/Chicago");
        Chronology lenient = StrictChronology.getInstance(ISOChronology.getInstance(zone));
        try {
            new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
            fail();
        } catch (IllegalArgumentException ex) {
View Full Code Here

Examples of org.joda.time.DateTimeZone

            // expected
        }
    }

    public void test_isoChrononolgy_Chicago() {
        DateTimeZone zone = DateTimeZone.forID("America/Chicago");
        Chronology lenient = ISOChronology.getInstance(zone);
        try {
            new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
            fail();
        } catch (IllegalArgumentException ex) {
View Full Code Here

Examples of org.joda.time.DateTimeZone

        assertEquals(true, gjUTC.hours().isPrecise());
        assertEquals(true, gjUTC.minutes().isPrecise());
        assertEquals(true, gjUTC.seconds().isPrecise());
        assertEquals(true, gjUTC.millis().isPrecise());
       
        final DateTimeZone gmt = DateTimeZone.forID("Etc/GMT");
        final GJChronology gjGMT = GJChronology.getInstance(gmt);
        assertEquals(false, gjGMT.centuries().isPrecise());
        assertEquals(false, gjGMT.years().isPrecise());
        assertEquals(false, gjGMT.weekyears().isPrecise());
        assertEquals(false, gjGMT.months().isPrecise());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.