Example usage for org.joda.time.format DateTimeFormatter print

List of usage examples for org.joda.time.format DateTimeFormatter print

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatter print.

Prototype

public String print(ReadablePartial partial) 

Source Link

Document

Prints a ReadablePartial to a new String.

Usage

From source file:com.sonicle.webtop.mail.bol.js.JsContactData.java

License:Open Source License

public JsContactData(Contact contact) {
    DateTimeFormatter ymdFmt = DateTimeUtils.createYmdFormatter();

    title = contact.getTitle();//  w ww  .  j a  va 2s .  co  m
    firstName = contact.getFirstName();
    lastName = contact.getLastName();
    nickname = contact.getNickname();
    gender = EnumUtils.toSerializedName(contact.getGender());
    mobile = contact.getMobile();
    pager1 = contact.getPager1();
    pager2 = contact.getPager2();
    email1 = contact.getEmail1();
    email2 = contact.getEmail2();
    email3 = contact.getEmail3();
    instantMsg1 = contact.getInstantMsg1();
    instantMsg2 = contact.getInstantMsg2();
    instantMsg3 = contact.getInstantMsg3();
    workAddress = contact.getWorkAddress();
    workPostalCode = contact.getWorkPostalCode();
    workCity = contact.getWorkCity();
    workState = contact.getWorkState();
    workCountry = contact.getWorkCountry();
    workTelephone1 = contact.getWorkTelephone1();
    workTelephone2 = contact.getWorkTelephone2();
    workFax = contact.getWorkFax();
    homeAddress = contact.getHomeAddress();
    homePostalCode = contact.getHomePostalCode();
    homeCity = contact.getHomeCity();
    homeState = contact.getHomeState();
    homeCountry = contact.getHomeCountry();
    homeTelephone1 = contact.getHomeTelephone1();
    homeTelephone2 = contact.getHomeTelephone2();
    homeFax = contact.getHomeFax();
    otherAddress = contact.getOtherAddress();
    otherPostalCode = contact.getOtherPostalCode();
    otherCity = contact.getOtherCity();
    otherState = contact.getOtherState();
    otherCountry = contact.getOtherCountry();
    company = contact.hasCompany() ? contact.getCompany().getIdOrValue() : null;
    function = contact.getFunction();
    department = contact.getDepartment();
    manager = contact.getManager();
    assistant = contact.getAssistant();
    assistantTelephone = contact.getAssistantTelephone();
    partner = contact.getPartner();
    birthday = (contact.getBirthday() != null) ? ymdFmt.print(contact.getBirthday()) : null;
    anniversary = (contact.getAnniversary() != null) ? ymdFmt.print(contact.getAnniversary()) : null;
    url = contact.getUrl();
    notes = contact.getNotes();
}

From source file:com.sonicle.webtop.mail.bol.js.JsPreviewMessage.java

License:Open Source License

public JsPreviewMessage(long uid, String folderid, String foldername, String subject, String from, String to,
        Date date, String text) {
    DateTimeFormatter ymdhmsZoneFmt = DateTimeUtils.createYmdHmsFormatter();
    String sdate = ymdhmsZoneFmt.print(new DateTime(date));
    this.uid = uid;
    this.folderid = folderid;
    this.foldername = foldername;
    this.subject = subject;
    this.from = from;
    this.to = to;
    this.date = sdate;
    this.text = text;
}

From source file:com.sonicle.webtop.mail.MailManager.java

License:Open Source License

private String buildSieveScriptHeader() {
    DateTimeFormatter fmt = DateTimeUtils.createYmdHmsFormatter();
    StringBuilder sb = new StringBuilder();
    sb.append("# Generated by WebTop [http://www.sonicle.com]");
    sb.append("\n");
    sb.append("# ").append(SERVICE_ID).append("@").append(WT.getManifest(SERVICE_ID).getVersion().toString());
    sb.append("\n");
    sb.append("# ").append(fmt.print(DateTimeUtils.now()));
    sb.append("\n");
    sb.append("\n");
    return sb.toString();
}

From source file:com.sonicle.webtop.tasks.TplHelper.java

License:Open Source License

private static String formatAsDate(DateTime dt, DateTimeFormatter fmt) {
    return (dt == null) ? "" : fmt.print(dt);
}

From source file:com.sonicle.webtop.vfs.bol.js.JsGridFile.java

License:Open Source License

private String getFileLastModified(FileObject fo) {
    DateTimeFormatter ymdhmsFmt = DateTimeUtils.createYmdHmsFormatter();

    try {//from   w w w  . j a va 2 s. c  om
        long millis = fo.getContent().getLastModifiedTime();
        return (millis == 0) ? "" : ymdhmsFmt.print(new DateTime(millis));
    } catch (FileSystemException ex) {
        return "";
    }
}

From source file:com.sos.jobnet.utils.TimeKeyCalculator.java

License:Apache License

public String convert(DateTimeFormatter toFormat) {
    return toFormat.print(calculatedTimeValue);
}

From source file:com.sos.scheduler.model.objects.JSObjDay.java

License:Apache License

private RunTimeElements getNextSingleStarts(DateTime baseDate) {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    DateTimeFormatter fmtDateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    RunTimeElements result = new RunTimeElements(baseDate);
    logger.debug(getDay().size() + " day elements detected.");
    Iterator<String> it = getDay().iterator();
    while (it.hasNext()) {
        String dayString = it.next();
        logger.debug("parsing day string " + dayString);
        List<Integer> days = JodaTools.getJodaWeekdays(dayString);
        for (int i = 0; i < days.size(); i++) {
            DateTime nextWeekDay = JodaTools.getNextWeekday(baseDate, days.get(i));
            logger.debug("calculated date " + fmtDate.print(nextWeekDay));
            List<Period> periods = getPeriod();
            Iterator<Period> itP = periods.iterator();
            logger.debug(periods.size() + " periods found.");
            while (itP.hasNext()) {
                Period p = itP.next();
                JSObjPeriod period = new JSObjPeriod(objFactory);
                period.setObjectFieldsFrom(p);
                DateTime start = period.getDtSingleStartOrNull(nextWeekDay);
                if (start != null) {
                    logger.debug("start from period " + fmtDateTime.print(start));
                    if (start.isBefore(baseDate)) {
                        start = start.plusWeeks(1);
                        logger.debug("start is corrected to " + fmtDateTime.print(start));
                    }//from   ww  w  .  ja  v  a 2s .c  o  m
                    RunTimeElement e = new RunTimeElement(start, period.getWhenHoliday());
                    result.add(e);
                }
            }
        }
        //         Collections.sort(result, DateTimeComparator.getInstance());
    }
    return result;
}

From source file:com.sos.scheduler.model.objects.JSObjHolidaysWeekdaysDay.java

License:Apache License

private List<DateTime> getNextSingleStarts(DateTime baseDate) {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    DateTimeFormatter fmtDateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    List<DateTime> result = new ArrayList<DateTime>();
    logger.debug(getDay().size() + " day elements detected.");
    Iterator<String> it = getDay().iterator();
    while (it.hasNext()) {
        String dayString = it.next();
        logger.debug("parsing day string " + dayString);
        List<Integer> days = JodaTools.getJodaWeekdays(dayString);
        for (int i = 0; i < days.size(); i++) {
            DateTime nextWeekDay = JodaTools.getNextWeekday(baseDate, days.get(i));
            logger.debug("calculated date " + fmtDate.print(nextWeekDay));
            if (nextWeekDay.isBefore(baseDate)) {
                nextWeekDay = nextWeekDay.plusWeeks(1);
                logger.debug("start is corrected to " + fmtDateTime.print(nextWeekDay));
            }/* w ww  . j a  v a 2  s.c  om*/
            result.add(nextWeekDay);
        }
        Collections.sort(result, DateTimeComparator.getInstance());
    }
    return result;
}

From source file:com.sos.scheduler.model.objects.JSObjPeriod.java

License:Apache License

private static DateTime getDate(DateTime baseDate, String timeString) {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    DateTimeFormatter fmtDateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    String dateString = fmtDate.print(baseDate) + " ";
    return fmtDateTime.parseDateTime(dateString + timeString);
}

From source file:com.sos.scheduler.model.objects.JSObjWeekdaysDay.java

License:Apache License

private RunTimeElements getNextSingleStarts(DateTime baseDate) {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd");
    DateTimeFormatter fmtDateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    RunTimeElements result = new RunTimeElements(baseDate);
    logger.debug(getDay().size() + " day elements detected.");
    Iterator<String> it = getDay().iterator();
    while (it.hasNext()) {
        String dayString = it.next();
        logger.debug("parsing day string " + dayString);
        List<Integer> days = JodaTools.getJodaWeekdays(dayString);
        for (int i = 0; i < days.size(); i++) {
            DateTime nextWeekDay = JodaTools.getNextWeekday(baseDate, days.get(i));
            logger.debug("calculated date " + fmtDate.print(nextWeekDay));
            List<Period> periods = getPeriod();
            Iterator<Period> itP = periods.iterator();
            logger.debug(periods.size() + " periods found.");
            while (itP.hasNext()) {
                Period p = itP.next();
                JSObjPeriod period = new JSObjPeriod(objFactory);
                period.setObjectFieldsFrom(p);
                DateTime start = period.getDtSingleStartOrNull(nextWeekDay);
                if (start != null) {
                    logger.debug("start from period " + fmtDateTime.print(start));
                    if (start.isBefore(baseDate)) {
                        start = start.plusWeeks(1);
                        logger.debug("start is corrected to " + fmtDateTime.print(start));
                    }//w ww . j  a  va  2s .c  o  m
                    result.add(new RunTimeElement(start, period.getWhenHoliday()));
                }
            }
        }
        //            Collections.sort(result, DateTimeComparator.getInstance());
    }
    return result;
}