Package org.joda.time

Examples of org.joda.time.DateTime


        // 14 hours
        settings.setTimeslotsPerDay(6 * 16);

        settings.setNumberOfDays(5);

        settings.setStartDate(new DateTime(2009, 6, 1, 8, 0, 0, 0));
    }
View Full Code Here


                                        if (endHour != 12) {
                                            endHour += 12;
                                        }
                                    }

                                    DateTime start = new DateTime(2009, 6, day, startHour, startMinute, 0, 0);
                                    DateTime end = new DateTime(2009, 6, day, endHour, endMinute, 0, 0);
                                    event.setStartDateTime(start);
                                    event.setEndDateTime(end);
                                }
                            }
                        }
View Full Code Here

       
        // convert to target time zone
        if (!utc) {
            milli -= zone.getOffset(milli);
        }
        return new DateTime(milli, zone);
    }
View Full Code Here

     */
    public static DateTime deserializeUTCDateTime(String text) throws JiBXException {
        if (text == null) {
            return null;
        } else {
            return new DateTime(Utility.parseDateTime(text), DateTimeZone.UTC);
        }
    }
View Full Code Here

        } catch (JiBXException ex) {}
    }
   
    public void testDeserializeUTCDateTime() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeUTCDateTime(null));
        DateTime time = JodaConvert.deserializeUTCDateTime("2008-02-28T01:02:03");
        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());
        assertEquals("Wrong value", 3, time.getSecondOfMinute());
        time = JodaConvert.deserializeUTCDateTime("2008-02-28T01:02:03Z");
        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());
        assertEquals("Wrong value", 3, time.getSecondOfMinute());
        time = JodaConvert.deserializeUTCDateTime("2008-02-29T02:05:06.123-02:00");
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        assertEquals("Wrong value", 29, time.getDayOfMonth());
        assertEquals("Wrong value", 4, time.getHourOfDay());
        assertEquals("Wrong value", 5, time.getMinuteOfHour());
        assertEquals("Wrong value", 6, time.getSecondOfMinute());
        assertEquals("Wrong value", 123, time.getMillisOfSecond());
        try {
            JodaConvert.deserializeUTCDateTime("2007-02-29T02:05:06.123-02:00");
            fail("Invalid day number");
        } catch (JiBXException ex) {}
        try {
View Full Code Here

        } catch (JiBXException ex) {}
    }
   
    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());
        } else {
            assertEquals("Wrong value", 28, time.getDayOfMonth());
            assertEquals("Wrong value", 1+OFFSET_HOURS, time.getHourOfDay());
        }
        assertEquals("Wrong value", 2, time.getMinuteOfHour());
        assertEquals("Wrong value", 3, time.getSecondOfMinute());
        time = JodaConvert.deserializeLocalDateTime("2008-02-29T02:05:06.123-02:00");
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        if (OFFSET_HOURS < -4) {
            assertEquals("Wrong value", 28, time.getDayOfMonth());
            assertEquals("Wrong value", 28+OFFSET_HOURS, time.getHourOfDay());
        } else {
            assertEquals("Wrong value", 29, time.getDayOfMonth());
            assertEquals("Wrong value", 4+OFFSET_HOURS, time.getHourOfDay());
        }
        assertEquals("Wrong value", 5, time.getMinuteOfHour());
        assertEquals("Wrong value", 6, time.getSecondOfMinute());
        assertEquals("Wrong value", 123, time.getMillisOfSecond());
        try {
            JodaConvert.deserializeLocalDateTime("2007-02-29T02:05:06.123-02:00");
            fail("Invalid day number");
        } catch (JiBXException ex) {}
        try {
View Full Code Here

        } catch (JiBXException ex) {}
    }
   
    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());
        assertEquals("Wrong value", 3, time.getSecondOfMinute());
        time = JodaConvert.deserializeStrictUTCDateTime("2008-02-29T02:05:06.123-02:00");
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        assertEquals("Wrong value", 29, time.getDayOfMonth());
        assertEquals("Wrong value", 4, time.getHourOfDay());
        assertEquals("Wrong value", 5, time.getMinuteOfHour());
        assertEquals("Wrong value", 6, time.getSecondOfMinute());
        assertEquals("Wrong value", 123, time.getMillisOfSecond());
        try {
            JodaConvert.deserializeStrictUTCDateTime("2007-02-29T02:05:06.123");
            fail("Accepted value without time zone");
        } catch (JiBXException ex) {}
    }
View Full Code Here

        } catch (JiBXException ex) {}
    }
   
    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());
        } else {
            assertEquals("Wrong value", 28, time.getDayOfMonth());
            assertEquals("Wrong value", 1+OFFSET_HOURS, time.getHourOfDay());
        }
        assertEquals("Wrong value", 2, time.getMinuteOfHour());
        assertEquals("Wrong value", 3, time.getSecondOfMinute());
        time = JodaConvert.deserializeStrictLocalDateTime("2008-02-29T02:05:06.123-02:00");
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        if (OFFSET_HOURS < -4) {
            assertEquals("Wrong value", 28, time.getDayOfMonth());
            assertEquals("Wrong value", 28+OFFSET_HOURS, time.getHourOfDay());
        } else {
            assertEquals("Wrong value", 29, time.getDayOfMonth());
            assertEquals("Wrong value", 4+OFFSET_HOURS, time.getHourOfDay());
        }
        assertEquals("Wrong value", 5, time.getMinuteOfHour());
        assertEquals("Wrong value", 6, time.getSecondOfMinute());
        assertEquals("Wrong value", 123, time.getMillisOfSecond());
        try {
            JodaConvert.deserializeStrictLocalDateTime("2007-02-29T02:05:06.123");
            fail("Accepted value without time zone");
        } catch (JiBXException ex) {}
    }
View Full Code Here

            fail("Accepted value without time zone");
        } catch (JiBXException ex) {}
    }
   
    public void testSerializeZonedDateTime() throws JiBXException {
        assertEquals("2008-02-28T05:06:07" + OFFSET_TEXT, JodaConvert.serializeZonedDateTime(new DateTime(2008, 2, 28, 5, 6, 7, 0)));
        assertEquals("2008-02-29T00:00:00.123" + OFFSET_TEXT, JodaConvert.serializeZonedDateTime(new DateTime(2008, 2, 29, 0, 0, 0, 123)));
        assertEquals("2008-03-01T23:59:59.999" + OFFSET_TEXT, JodaConvert.serializeZonedDateTime(new DateTime(2008, 3, 1, 23, 59, 59, 999)));
        assertEquals("2008-02-28T05:06:07Z", JodaConvert.serializeZonedDateTime(new DateTime(2008, 2, 28, 5, 6, 7, 0, DateTimeZone.UTC)));
    }
View Full Code Here

        assertEquals("2008-03-01T23:59:59.999" + OFFSET_TEXT, JodaConvert.serializeZonedDateTime(new DateTime(2008, 3, 1, 23, 59, 59, 999)));
        assertEquals("2008-02-28T05:06:07Z", JodaConvert.serializeZonedDateTime(new DateTime(2008, 2, 28, 5, 6, 7, 0, DateTimeZone.UTC)));
    }
   
    public void testSerializeUTCDateTime() throws JiBXException {
        assertEquals("2008-02-27T23:06:07Z", JodaConvert.serializeUTCDateTime(new DateTime(2008, 2, 28, 12, 6, 7, 0, DateTimeZone.forOffsetHours(13))));
        assertEquals("2008-02-29T01:06:07Z", JodaConvert.serializeUTCDateTime(new DateTime(2008, 2, 28, 12, 6, 7, 0, DateTimeZone.forOffsetHours(-13))));
        assertEquals("2008-03-01T23:59:59.999Z", JodaConvert.serializeUTCDateTime(new DateTime(2008, 3, 1, 23, 59, 59, 999, DateTimeZone.UTC)));
    }
View Full Code Here

TOP

Related Classes of org.joda.time.DateTime

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.