Package org.joda.time

Examples of org.joda.time.DateTime


        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

    }

    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);

            final StringBuilder sb = new StringBuilder(29);
View Full Code Here

        final int countTodaysMessages  = MessageStorage.inst().getMessageCount(board, 0);
        final int countAllMessages     = MessageStorage.inst().getMessageCount(board, -1);
        final int countFlaggedMessages = MessageStorage.inst().getFlaggedMessageCount(board);
        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

      sb.append("<b>Expression</b>:\n");
      sb.append(regex.getExpression());
      sb.append("\n\n<b>Description</b>:\n");
      sb.append(regex.getDescription());
      sb.append("\n\n<b>Submission date</b>:\n");
      sb.append(new DateTime(regex.getTimestamp() * 1000).toString());

      _regexDescriptionLabel.setText(sb.toString());
      _importRegexButton.setEnabled(true);
      _viewOnlineButton.setEnabled(true);
    }
 
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.