Package org.joda.time

Examples of org.joda.time.DateMidnight


        if (day < 1 || day > (starts[month]-starts[month-1])) {
            throw new JiBXException("Day value out of range");
        }
       
        // return resulting value
        return new DateMidnight(year, month, day, zone);
    }
View Full Code Here


        assertEquals("2008-03-01", JodaConvert.serializeLocalDate(new LocalDate(2008, 3, 1)));
    }
   
    public void testDeserializeZonedDateMidnight() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeZonedDateMidnight(null));
        DateMidnight date = JodaConvert.deserializeZonedDateMidnight("2008-02-28");
        DateTimeZone zone = date.getZone();
        assertEquals(OFFSET_MILLIS, zone.getOffset(date));
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 28, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        date = JodaConvert.deserializeZonedDateMidnight("2008-02-29Z");
        zone = date.getZone();
        assertEquals(0, zone.getOffset(date));
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        date = JodaConvert.deserializeZonedDateMidnight("2008-02-29-12:30");
        zone = date.getZone();
        assertEquals("Expected -12:30 timezone", -750*60*1000, zone.getOffset(date));
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        try {
            JodaConvert.deserializeZonedDateMidnight("2007-02-29");
            fail("Invalid day number");
        } catch (JiBXException ex) {}
        try {
View Full Code Here

        } catch (Exception ex) {}
    }
   
    public void testDeserializeDefaultDateMidnight() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeLocalDateMidnight(null));
        DateMidnight date = JodaConvert.deserializeLocalDateMidnight("2008-02-28");
        DateTimeZone zone = date.getZone();
        assertEquals(OFFSET_MILLIS, zone.getOffset(date));
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 28, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        date = JodaConvert.deserializeLocalDateMidnight("2008-02-29Z");
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        date = JodaConvert.deserializeLocalDateMidnight("2008-02-29-24:00");
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        try {
            JodaConvert.deserializeLocalDateMidnight("2007-02-29");
            fail("Invalid day number");
        } catch (JiBXException ex) {}
        try {
View Full Code Here

        } catch (Exception ex) {}
    }
   
    public void testDeserializeUTCDateMidnight() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeUTCDateMidnight(null));
        DateMidnight date = JodaConvert.deserializeUTCDateMidnight("2008-02-28");
        DateTimeZone zone = date.getZone();
        assertEquals("UTC timezone expected", "UTC", zone.getID());
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 28, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        date = JodaConvert.deserializeUTCDateMidnight("2008-02-29Z");
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        date = JodaConvert.deserializeUTCDateMidnight("2008-02-29-24:00");
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        assertEquals("Wrong value", 0, date.getHourOfDay());
        assertEquals("Wrong value", 0, date.getMinuteOfHour());
        assertEquals("Wrong value", 0, date.getSecondOfMinute());
        try {
            JodaConvert.deserializeUTCDateMidnight("2007-02-29");
            fail("Invalid day number");
        } catch (JiBXException ex) {}
        try {
View Full Code Here

            fail("Invalid month number");
        } catch (JiBXException ex) {}
    }
   
    public void testSerializeUnzonedDateMidnight() throws JiBXException {
        assertEquals("2008-02-28", JodaConvert.serializeUnzonedDateMidnight(new DateMidnight(2008, 2, 28)));
        assertEquals("2008-02-29", JodaConvert.serializeUnzonedDateMidnight(new DateMidnight(2008, 2, 29)));
        assertEquals("2008-03-01", JodaConvert.serializeUnzonedDateMidnight(new DateMidnight(2008, 3, 1)));
    }
View Full Code Here

        assertEquals("2008-02-29", JodaConvert.serializeUnzonedDateMidnight(new DateMidnight(2008, 2, 29)));
        assertEquals("2008-03-01", JodaConvert.serializeUnzonedDateMidnight(new DateMidnight(2008, 3, 1)));
    }
   
    public void testSerializeZonedDateMidnight() throws JiBXException {
        assertEquals("2008-02-28" + OFFSET_TEXT, JodaConvert.serializeZonedDateMidnight(new DateMidnight(2008, 2, 28)));
        assertEquals("2008-02-29" + OFFSET_TEXT, JodaConvert.serializeZonedDateMidnight(new DateMidnight(2008, 2, 29)));
        assertEquals("2008-03-01" + OFFSET_TEXT, JodaConvert.serializeZonedDateMidnight(new DateMidnight(2008, 3, 1)));
    }
View Full Code Here

        assertEquals("2008-02-29" + OFFSET_TEXT, JodaConvert.serializeZonedDateMidnight(new DateMidnight(2008, 2, 29)));
        assertEquals("2008-03-01" + OFFSET_TEXT, JodaConvert.serializeZonedDateMidnight(new DateMidnight(2008, 3, 1)));
    }
   
    public void testSerializeUTCDateMidnight() throws JiBXException {
        assertEquals("2008-02-28Z", JodaConvert.serializeUTCDateMidnight(new DateMidnight(2008, 2, 28)));
        assertEquals("2008-02-29Z", JodaConvert.serializeUTCDateMidnight(new DateMidnight(2008, 2, 29)));
        assertEquals("2008-03-01Z", JodaConvert.serializeUTCDateMidnight(new DateMidnight(2008, 3, 1)));
        assertEquals("2008-02-28Z", JodaConvert.serializeUTCDateMidnight(new DateMidnight(2008, 2, 28, DateTimeZone.UTC)));
        assertEquals("2008-02-29Z", JodaConvert.serializeUTCDateMidnight(new DateMidnight(2008, 2, 29, DateTimeZone.UTC)));
        assertEquals("2008-03-01Z", JodaConvert.serializeUTCDateMidnight(new DateMidnight(2008, 3, 1, DateTimeZone.UTC)));
    }
View Full Code Here

            if( lastSeen < 0 ) {
                // not set!
                return "";
            }
            String lsStr = DateFun.FORMAT_DATE_EXT.print(lastSeen);
            long days = new DateMidnight(DateTimeZone.UTC).getMillis() - new DateMidnight(lastSeen, DateTimeZone.UTC).getMillis();
            days /= 1000L * 60L * 60L * 24L;
            lsStr += "  ("+days+")";

            return lsStr;
        }
View Full Code Here

    public String getDateAndTimeString() {
        if( dateAndTimeString == null ) {
            // Build a String of format yyyy.mm.dd hh:mm:ssGMT
            final DateTime dateTime = new DateTime(getDateAndTime(), DateTimeZone.UTC);
            final DateMidnight date = dateTime.toDateMidnight();
            final TimeOfDay time = dateTime.toTimeOfDay();

            final String dateStr = DateFun.FORMAT_DATE_EXT.print(date);
            final String timeStr = DateFun.FORMAT_TIME_EXT.print(time);
View Full Code Here

        final int countStarredMessages = MessageStorage.inst().getStarredMessageCount(board);
        final int countUnreadMessages  = MessageStorage.inst().getUnreadMessageCount(board);
        final DateTime dateTime = MessageStorage.inst().getDateTimeOfLatestMessage(board);
        final String dateStr;
        if (dateTime != null) {
            final DateMidnight date = dateTime.toDateMidnight();
            dateStr = DateFun.FORMAT_DATE_EXT.print(date);
        } else {
            dateStr = "---";
        }
View Full Code Here

TOP

Related Classes of org.joda.time.DateMidnight

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.