Package org.joda.time

Examples of org.joda.time.DateTime$Property


        } 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

        assertEquals("00:00:00.123Z", JodaConvert.serializeUTCLocalTime(new LocalTime(0, 0, 0, 123)));
    }
   
    public void testDeserializeZonedDateTime() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeZonedDateTime(null));
        DateTime time = JodaConvert.deserializeZonedDateTime("2008-02-28T01:02:03");
        DateTimeZone zone = time.getZone();
        assertEquals("Default timezone expected", OFFSET_MILLIS, zone.getOffset(time));
        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-29T24:00:00Z");
        zone = time.getZone();
        assertEquals("UTC timezone expected", "UTC", zone.getID());
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 3, time.getMonthOfYear());
        assertEquals("Wrong value", 1, time.getDayOfMonth());
        assertEquals("Wrong value", 0, time.getHourOfDay());
        assertEquals("Wrong value", 0, time.getMinuteOfHour());
        assertEquals("Wrong value", 0, time.getSecondOfMinute());
        time = JodaConvert.deserializeZonedDateTime("2008-02-29T02:05:06.123-02:30");
        zone = time.getZone();
        assertEquals("Expected -02:30 timezone", -150*60*1000, zone.getOffset(time));
        assertEquals("Wrong value", 2008, time.getYear());
        assertEquals("Wrong value", 2, time.getMonthOfYear());
        assertEquals("Wrong value", 29, time.getDayOfMonth());
        assertEquals("Wrong value", 2, time.getHourOfDay());
        assertEquals("Wrong value", 5, time.getMinuteOfHour());
        assertEquals("Wrong value", 6, time.getSecondOfMinute());
        assertEquals("Wrong value", 123, time.getMillisOfSecond());
        try {
            JodaConvert.deserializeZonedDateTime("2007-02-29T02:05:06.123-02:00");
            fail("Invalid day number");
        } catch (JiBXException ex) {}
        try {
View Full Code Here

    * @return The ISO 8601 Period like "P3Y6M4DT12H30M17S"
    */
   public static String getDifferenceToNow(String utc) {
     if (utc == null) return "";
     utc = ReplaceVariable.replaceAll(utc, " ", "T");
     DateTime now = new DateTime();
     DateTimeFormatter f = ISODateTimeFormat.dateTimeParser();
     DateTime other = f.parseDateTime(utc);
     Period period = new Period(other, now); // Period(ReadableInstant startInstant, ReadableInstant endInstant)
     return period.toString();
   }
View Full Code Here

            to.isReply = isReply;
            to.recipient = recipient;
            to.senderId = senderId;
            // create a temporary editText that is show in alternate editor
            // the editor will return only new text to us
            final DateTime now = new DateTime(DateTimeZone.UTC);
            final String date = DateFun.FORMAT_DATE_EXT.print(now)
            + " - "
            + DateFun.FORMAT_TIME_EXT.print(now);
            final String fromLine = "----- (sender) ----- " + date + " -----";
            final String editText = newText + fromLine + "\n\n";
View Full Code Here

        }

        updateSignToolTip();

        // prepare message text
        final DateTime now = new DateTime(DateTimeZone.UTC);
        final String date = DateFun.FORMAT_DATE_EXT.print(now)
                        + " - "
                        + DateFun.FORMAT_TIME_EXT.print(now);
        final String fromLine = "----- " + from + " ----- " + date + " -----";
View Full Code Here

    public FrostMessageObject() {
    }

    public FrostMessageObject(final boolean isRootnode) {
        setDummy(true);
        setDateAndTime(new DateTime(0, DateTimeZone.UTC));
        setSubject("(root)");
        setNew(false);
        setFromName("");
    }
View Full Code Here

        try {
            setDateAndTime(mof.getDateAndTime());
        } catch(final Throwable t) {
            // never happens, we already called this method
            setDateAndTime(new DateTime(0, DateTimeZone.UTC));
        }
//        System.out.println("MSG TIME/DATE: time_in="+mof.getTimeStr()+", date_in="+mof.getDateStr()+", out="+getDateAndTime());
        // copy values from mof
        setAttachmentList(mof.getAttachmentList());
        setContent(mof.getContent());
View Full Code Here

        setMessageId(msgId);
        setBoard(b);
        setDummyInReplyToList(ll);

        setDummy(true);
        setDateAndTime(new DateTime(0, DateTimeZone.UTC));
        setSubject("");
        setNew(false);
        setFromName("");
    }
View Full Code Here

TOP

Related Classes of org.joda.time.DateTime$Property

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.