Example usage for com.liferay.portal.kernel.util FastDateFormatFactoryUtil getDate

List of usage examples for com.liferay.portal.kernel.util FastDateFormatFactoryUtil getDate

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util FastDateFormatFactoryUtil getDate.

Prototype

public static Format getDate(TimeZone timeZone) 

Source Link

Usage

From source file:com.gleo.groupphoto.web.portlet.action.ViewUserDetailsActionMVCRenderCommand.java

License:Open Source License

/**
 * Set fields/*from   ww  w . j  a  v  a 2  s .  c  om*/
 * 
 * @param renderRequest
 * @param contact
 * @param user
 * @param company
 * @param locale
 * @param birthday
 * @param gender
 * @param jobTitle
 */
private void setFields(RenderRequest renderRequest, Contact contact, User user, Company company, Locale locale,
        String birthday, String gender, String jobTitle) {

    boolean isFieldEnableContactBirthday = PrefsPropsUtil.getBoolean(company.getCompanyId(),
            PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_BIRTHDAY);

    if (isFieldEnableContactBirthday) {
        Format dateFormatDate = FastDateFormatFactoryUtil.getDate(locale);
        try {
            birthday = dateFormatDate.format(user.getBirthday());
        } catch (PortalException e) {
            LOGGER.error(e);
        }
    }

    jobTitle = HtmlUtil.escape(contact.getJobTitle());

    boolean isFieldEnableContactMale = PrefsPropsUtil.getBoolean(company.getCompanyId(),
            PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_MALE);

    if (isFieldEnableContactMale) {
        try {
            gender = LanguageUtil.get(locale, user.isMale() ? "male" : "female");
        } catch (PortalException pe) {
            LOGGER.error(pe);
        }
    }

    renderRequest.setAttribute("birthday", birthday);
    renderRequest.setAttribute("jobTitle", jobTitle);
    renderRequest.setAttribute("gender", gender);
}

From source file:com.liferay.portlet.dynamicdatamapping.storage.DateFieldRenderer.java

License:Open Source License

@Override
protected String doRender(ThemeDisplay themeDisplay, Field field) {
    Serializable value = field.getValue();

    if (Validator.isNull(value)) {
        return StringPool.BLANK;
    }//from   www. jav  a2 s  .  c om

    Format format = FastDateFormatFactoryUtil.getDate(themeDisplay.getLocale());

    return format.format(value);
}