Example usage for org.apache.commons.lang.time FastDateFormat getDateTimeInstance

List of usage examples for org.apache.commons.lang.time FastDateFormat getDateTimeInstance

Introduction

In this page you can find the example usage for org.apache.commons.lang.time FastDateFormat getDateTimeInstance.

Prototype

public static FastDateFormat getDateTimeInstance(int dateStyle, int timeStyle, TimeZone timeZone) 

Source Link

Document

Gets a date/time formatter instance using the specified style and time zone in the default locale.

Usage

From source file:info.magnolia.cms.util.DateUtil.java

/**
 * Uses the current locale (user) to format the date and time
 * @param val Date or Calendar/*from ww w  .  ja  v  a  2  s. c  om*/
 * @return the String
 */
public static String formatDateTime(Object val) {
    FastDateFormat format = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT,
            MgnlContext.getLocale());
    return format.format(val);
}

From source file:com.manydesigns.portofino.pageactions.activitystream.ActivityItem.java

public ActivityItem(Locale locale, Date timestamp, String imageSrc, String imageHref, String imageAlt,
        String message, String key) {
    this.locale = locale;
    this.timestamp = timestamp;
    this.imageSrc = imageSrc;
    this.imageHref = imageHref;
    this.imageAlt = imageAlt;
    this.message = message;
    this.key = key;

    dateFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL, locale);
}

From source file:com.benfante.minimark.blo.AssessmentXMLFOBuilder.java

private StringBuilder makeHeader(StringBuilder result, AssessmentFilling assessment, Locale locale) {
    FastDateFormat dateTimeFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT,
            FastDateFormat.SHORT, locale);
    result.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>").append('\n');
    result.append("<!DOCTYPE root [").append('\n');
    result.append("  <!ELEMENT root (#PCDATA) >").append('\n');
    result.append(//  ww w.j a v  a 2 s.  c  o  m
            "    <!ENTITY rchk '<fo:external-graphic src=\"url(&apos;images/interface/rchk.gif&apos;)\" content-height=\"9pt\" content-width=\"9pt\"/>' >")
            .append('\n');
    result.append(
            "    <!ENTITY ruchk '<fo:external-graphic src=\"url(&apos;images/interface/ruchk.gif&apos;)\" content-height=\"9pt\" content-width=\"9pt\"/>' >")
            .append('\n');
    result.append(
            "    <!ENTITY cchk '<fo:external-graphic src=\"url(&apos;images/interface/cchk.jpg&apos;)\" content-height=\"9pt\" content-width=\"9pt\"/>' >")
            .append('\n');
    result.append(
            "    <!ENTITY cuchk '<fo:external-graphic src=\"url(&apos;images/interface/cuchk.jpg&apos;)\" content-height=\"9pt\" content-width=\"9pt\"/>' >")
            .append('\n');
    result.append("    <!ENTITY agrave '&#xe0;' >").append('\n');
    result.append("    <!ENTITY egrave '&#xe8;' >").append('\n');
    result.append("    <!ENTITY igrave '&#xec;' >").append('\n');
    result.append("    <!ENTITY ograve '&#xf2;' >").append('\n');
    result.append("    <!ENTITY ugrave '&#xf9;' >").append('\n');
    result.append("    <!ENTITY aacute '&#xe1;' >").append('\n');
    result.append("    <!ENTITY eacute '&#xe9;' >").append('\n');
    result.append("    <!ENTITY iacute '&#xed;' >").append('\n');
    result.append("    <!ENTITY oacute '&#xf3;' >").append('\n');
    result.append("    <!ENTITY uacute '&#xfa;' >").append('\n');
    result.append("]>").append('\n');
    result.append("<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">").append('\n');
    result.append("  <fo:layout-master-set>").append('\n');
    result.append(
            "    <fo:simple-page-master master-name=\"normal\" page-height=\"210mm\" page-width=\"297mm\" margin-top=\"1cm\" margin-bottom=\"0.5cm\" margin-left=\"1.5cm\" margin-right=\"1.5cm\">")
            .append('\n');
    result.append(
            "      <fo:region-body margin-top=\"0cm\" margin-bottom=\"1.5cm\" column-count=\"2\" column-gap=\"0.25in\"/>")
            .append('\n');
    result.append("      <fo:region-before extent=\"0cm\"/>").append('\n');
    result.append("      <fo:region-after extent=\"1cm\"/>").append('\n');
    result.append("    </fo:simple-page-master>").append('\n');

    result.append(
            "    <fo:simple-page-master master-name=\"blank\" page-height=\"210mm\" page-width=\"297mm\" margin-top=\"1cm\" margin-bottom=\"0.5cm\" margin-left=\"1.5cm\" margin-right=\"1.5cm\">")
            .append('\n');
    result.append("      <fo:region-body/>").append('\n');
    result.append("      <fo:region-before region-name=\"header-blank\" extent=\"297mm\"/>").append('\n');
    result.append("      <fo:region-after extent=\"1cm\"/>").append('\n');
    result.append("    </fo:simple-page-master>").append('\n');
    result.append("    <fo:page-sequence-master master-name=\"all\">").append('\n');
    result.append("      <fo:repeatable-page-master-alternatives>").append('\n');
    result.append(
            "        <fo:conditional-page-master-reference blank-or-not-blank=\"not-blank\" master-reference=\"normal\"/>")
            .append('\n');
    result.append(
            "        <fo:conditional-page-master-reference blank-or-not-blank=\"blank\" master-reference=\"blank\"/>")
            .append('\n');
    result.append("      </fo:repeatable-page-master-alternatives>").append('\n');
    result.append("    </fo:page-sequence-master>").append('\n');

    result.append("  </fo:layout-master-set>").append('\n');
    result.append(
            "  <fo:page-sequence id=\"assprintseq\" master-reference=\"all\" font-family=\"sans-serif\" font-size=\"9pt\" line-height=\"11pt\" space-after.optimum=\"12pt\" force-page-count=\"end-on-even\">")
            .append('\n');

    result.append("    <fo:static-content flow-name=\"header-blank\">");
    result.append("      <fo:block space-before=\"100mm\" text-align-last=\"center\">").append(
            messageSource.getMessage("IntentionallyLeftBlank", null, "?IntentionallyLeftBlank?", locale))
            .append("</fo:block>");
    result.append("    </fo:static-content>");

    result.append("    <fo:static-content flow-name=\"xsl-region-after\">").append('\n');
    result.append("      <fo:block>").append('\n');
    result.append("        <fo:table table-layout=\"fixed\" width=\"264mm\">").append('\n');
    result.append("          <fo:table-column column-width=\"88mm\"/>").append('\n');
    result.append("          <fo:table-column column-width=\"88mm\"/>").append('\n');
    result.append("          <fo:table-column column-width=\"88mm\"/>").append('\n');
    result.append("          <fo:table-body>").append('\n');
    result.append("            <fo:table-row>").append('\n');
    result.append("              <fo:table-cell text-align=\"start\">").append('\n');
    result.append("                <fo:block>").append('\n');
    result.append("                  <![CDATA[").append(assessment.getIdentifier()).append(' ')
            .append(assessment.getFirstName()).append(' ').append(assessment.getLastName()).append("]]>")
            .append('\n');
    result.append("                </fo:block>").append('\n');
    result.append("              </fo:table-cell>").append('\n');
    result.append("              <fo:table-cell text-align=\"center\">").append('\n');
    result.append("                <fo:block>").append('\n');
    result.append("                  ")
            .append(assessment.getSubmittedDate() != null ? dateTimeFormat.format(assessment.getSubmittedDate())
                    : messageSource.getMessage("NotSubmitted", null, "?NotSubmitted?", locale))
            .append('\n');
    result.append("                </fo:block>").append('\n');
    result.append("              </fo:table-cell>").append('\n');
    result.append("              <fo:table-cell text-align=\"end\">").append('\n');
    result.append("                <fo:block>").append('\n');
    result.append(messageSource.getMessage("PageNOfM",
            new String[] { "<fo:page-number/>", "<fo:page-number-citation-last ref-id='assprintseq'/>" },
            "?PageNOfM?", locale)).append('\n');
    result.append("                </fo:block>").append('\n');
    result.append("              </fo:table-cell>").append('\n');
    result.append("            </fo:table-row>").append('\n');
    result.append("          </fo:table-body>").append('\n');
    result.append("        </fo:table>").append('\n');
    result.append("      </fo:block>").append('\n');
    result.append("    </fo:static-content>").append('\n');
    result.append("    <fo:flow flow-name=\"xsl-region-body\">").append('\n');
    result.append("      <fo:block font-size=\"11pt\" font-weight=\"bold\" text-align=\"center\">")
            .append('\n');
    result.append("        <fo:block space-after=\"11pt\">").append(assessment.getAssessment().getTitle())
            .append("</fo:block>").append('\n');
    result.append("        <fo:block>")
            .append(messageSource.getMessage("Incumbent", null, "?Incumbent?", locale)).append(": ")
            .append(assessment.getAssessment().getCourse().getIncumbent()).append("</fo:block>").append('\n');
    result.append("        <fo:block>").append(dateTimeFormat.format(assessment.getStartDate()))
            .append("</fo:block>").append('\n');
    result.append("      </fo:block>").append('\n');
    return result;
}