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.contacts.bol.js.JsContact.java

License:Open Source License

public JsContact(UserProfileId ownerId, Contact contact) {
    DateTimeFormatter ymdFmt = DateTimeUtils.createYmdFormatter();

    id = contact.getContactId();/*w w  w.j  a  v  a  2s.  c om*/
    categoryId = contact.getCategoryId();
    displayName = contact.getDisplayName();
    title = contact.getTitle();
    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();
    picture = contact.hasPicture() ? String.valueOf(id) : null;

    attachments = new ArrayList<>();
    for (ContactAttachment att : contact.getAttachments()) {
        Attachment jsatt = new Attachment();
        jsatt.id = att.getAttachmentId();
        //jsatt.lastModified = DateTimeUtils.printYmdHmsWithZone(att.getRevisionTimestamp(), profileTz);
        jsatt.name = att.getFilename();
        jsatt.size = att.getSize();
        attachments.add(jsatt);
    }

    _profileId = ownerId.toString();
}

From source file:com.sonicle.webtop.contacts.UserOptionsService.java

License:Open Source License

@Override
public void processUserOptions(HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
    Connection con = null;/*from  w w  w .j  av  a2s  . c o m*/

    try {
        String crud = ServletUtils.getStringParameter(request, "crud", true);
        ContactsUserSettings cus = new ContactsUserSettings(SERVICE_ID, getTargetProfileId());
        DateTimeFormatter hmf = DateTimeUtils.createHmFormatter();

        if (crud.equals(Crud.READ)) {
            JsUserOptions jso = new JsUserOptions(getTargetProfileId().toString());

            // Main
            jso.view = EnumUtils.toSerializedName(cus.getView());
            jso.showBy = EnumUtils.toSerializedName(cus.getShowBy());
            jso.anniversaryReminderDelivery = cus.getAnniversaryReminderDelivery();
            jso.anniversaryReminderTime = hmf.print(cus.getAnniversaryReminderTime());

            new JsonResult(jso).printTo(out);

        } else if (crud.equals(Crud.UPDATE)) {
            Payload<MapItem, JsUserOptions> pl = ServletUtils.getPayload(request, JsUserOptions.class);

            // Main
            if (pl.map.has("view"))
                cus.setView(pl.data.view);
            if (pl.map.has("showBy"))
                cus.setShowBy(pl.data.showBy);
            if (pl.map.has("anniversaryReminderDelivery"))
                cus.setAnniversaryReminderDelivery(pl.data.anniversaryReminderDelivery);
            if (pl.map.has("anniversaryReminderTime"))
                cus.setAnniversaryReminderTime(hmf.parseLocalTime(pl.data.anniversaryReminderTime));

            new JsonResult().printTo(out);
        }

    } catch (Exception ex) {
        logger.error("Error executing UserOptions", ex);
        new JsonResult(false).printTo(out);
    } finally {
        DbUtils.closeQuietly(con);
    }
}

From source file:com.sonicle.webtop.core.bol.js.JsGridIMChatSearch.java

License:Open Source License

public JsGridIMChatSearch(IMMessage message, String senderNick, DateTimeZone utz) {
    DateTimeFormatter fmt = DateTimeUtils.createYmdHmsFormatter(utz);

    this.id = message.getMessageUid();
    this.fromId = message.getSenderJid();
    this.fromNick = senderNick;
    this.date = message.getTimestampDate(utz).toString();
    this.timestamp = fmt.print(message.getTimestamp());
    this.action = EnumUtils.toSerializedName(message.getAction());
    this.text = message.getText();
}

From source file:com.sonicle.webtop.core.bol.js.JsGridIMMessage.java

License:Open Source License

public JsGridIMMessage(boolean isSent, IMMessage message, String senderNick, DateTimeZone utz) {
    DateTimeFormatter ymdhms = DateTimeUtils.createYmdHmsFormatter(utz);

    this.id = message.getMessageUid();
    this.fromId = message.getSenderJid();
    this.fromNick = senderNick;
    this.isSent = isSent;
    this.timestamp = ymdhms.print(message.getTimestamp());
    this.action = EnumUtils.toSerializedName(message.getAction());
    this.text = message.getText();
    this.data = message.getData();
    this.fromArchive = true;
}

From source file:com.sonicle.webtop.core.bol.js.JsGridIMMessage.java

License:Open Source License

public JsGridIMMessage(boolean isSent, ChatMessage message, DateTimeZone utz) {
    DateTimeFormatter fmt = DateTimeUtils.createYmdHmsFormatter(utz);

    this.id = message.getMessageUid();
    this.fromId = message.getFromUser().toString();
    this.fromNick = message.getFromUserNickname();
    this.isSent = isSent;
    this.timestamp = fmt.print(message.getTimestamp());
    this.action = EnumUtils.toSerializedName(IMMessage.Action.NONE);
    this.text = message.getText();
    this.data = null;
    OutOfBandData oob = message.getOutOfBandExtension();
    if (oob != null) {
        this.action = EnumUtils.toSerializedName(IMMessage.Action.FILE);
        this.data = JsGridIMMessage.toData(message.getText(), oob);
    }/*from   w  w w  .  j a va 2  s.  c  om*/
    this.fromArchive = false;
}

From source file:com.sonicle.webtop.core.bol.js.JsGridIMMessage.java

License:Open Source License

public static JsGridIMMessage asDateAction(String id, LocalDate date) {
    DateTimeFormatter ymd = DateTimeUtils.createYmdFormatter();
    return new JsGridIMMessage("!" + id, null, null, false, ymd.print(date) + " 00:00:00", "date", null, null,
            false);/*from   ww w  .ja  v  a 2  s.  c o  m*/
}

From source file:com.sonicle.webtop.core.bol.js.JsGridIMMessage.java

License:Open Source License

public static JsGridIMMessage asWarnAction(String id, DateTime timestamp, String key) {
    DateTimeFormatter ymdmhs = DateTimeUtils.createYmdHmsFormatter();
    return new JsGridIMMessage("!" + id, null, null, false, ymdmhs.print(timestamp), "warn", key, null, false);
}

From source file:com.sonicle.webtop.core.bol.js.JsGridSync.java

License:Open Source License

public JsGridSync(String device, String user, DateTime lastSync, DateTimeFormatter fmt) {
    this.id = new CompositeId().setTokens(device, user).toString();
    this.device = device;
    this.user = user;
    if (lastSync != null) {
        this.lastSync = fmt.print(lastSync);
    } else {/*from ww  w .j a va2 s  .  c om*/
        this.lastSync = null;
    }
}

From source file:com.sonicle.webtop.core.sdk.BaseSettings.java

License:Open Source License

public boolean setTime(String key, LocalTime value, String pattern) {
    DateTimeFormatter dtf = DateTimeUtils.createFormatter(pattern);
    return setString(key, (value == null) ? null : dtf.print(value));
}

From source file:com.sonicle.webtop.core.sdk.BaseSettings.java

License:Open Source License

public boolean setDateTime(String key, DateTime value, DateTimeZone dtz) {
    DateTimeFormatter dtf = DateTimeUtils.createYmdHmsFormatter(dtz);
    return setString(key, (value == null) ? null : dtf.print(value));
}