BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.

com.bea.wlw.netui.tags.html
Class FormatDate

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.bea.wlw.netui.tags.AbstractBaseTag
              extended by com.bea.wlw.netui.tags.html.FormatTag
                  extended by com.bea.wlw.netui.tags.html.FormatDate
All Implemented Interfaces:
HtmlConstants, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class FormatDate
extends FormatTag

A formatter used to format dates. This formatter uses patterns that conform to java.text.SimpleDateFormat pattern syntax. Valid types for formatting are:

If the type is a String, we attempt to create a date out of the String. The String must be defined by a common format list below. If the string is equal the the empty string, it will be returned as the empty string. See java.text.SimpleDateFormat for more information.

The valid formats are:

Attribute Descriptions
AttributeRequiredRuntime Expression EvaluationData Bindable
countryNoNoNo
The country code used to determine the locale.
languageNoNoNo
The language code used to determine the locale.
patternNoNoRead Only
The SimpleDateFormat pattern used to format this date.
stringInputPatternNoNoRead Only
The pattern used to convert a String value into a date.

See Also:
FormatNumber, FormatString, java.text.NumberFormat, Serialized Form
Example:
In this sample, the <netui:label> tag's output will be formatted to something like 08/29/1957.
    <netui:label value="{pageContext.today}">
        <netui:formatDate pattern="MM/dd/yyyy" />
    </netui:label>

Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui/formatTags/index.jsp
Beadoc.see:
<netui:format...> Tag Samples
Beadoc.tagdescription:
A formatter used to format dates. This formatter uses patterns that conform to java.text.SimpleDateFormat pattern syntax. Valid types for formatting are:
  • String
  • java.sql.Date
  • java.util.Date
  • java.util.Calendar

The <netui:formatDate> tag formats the output of its parent tag. For example:

    <netui:content value="{pageContext.euroDate}">
        <netui:formatDate pattern="dd-MM-yyyy" />
    </netui:content>

The following table summarizes the pattern letters that can be used.

Letter Date or Time Component Examples
G Era designator AD
y Year 1996; 96
M Month in year July; Jul; 07
w Week in year 27
W Week in month 2
D Day in year 189
d Day in month 10
F Day of week in month 2
E Day in week Tuesday; Tue
a Am/pm marker PM
H Hour in day (0-23) 0
k Hour in day (1-24) 24
K Hour in am/pm (0-11) 0
h Hour in am/pm (1-12) 12
m Minute in hour 30
s Second in minute 55
S Millisecond 978
z Time zone Pacific Standard Time; PST; GMT-08:00
Z Time zone -0800

The number of pattern letters used determines the final presentation. For example, yy specifies a 2 digit year, while yyyy specifies a four digit year. For detailed information see java.text.SimpleDateFormat.

If the input type is a String, <netui:formatDate> attempts to convert the String into a java.util.Date object before formatting. For the conversion to succeed, the String must conform to a format listed below.

The valid formats are:

  • MM/dd/yy
  • yyyy-MM-dd
  • MMddyy
  • the local default

Nested Class Summary
static class FormatDate.DateFormatter
          Internal FormatTag.Formatter which uses SimpleDateFormat.
 
Nested classes/interfaces inherited from class com.bea.wlw.netui.tags.html.FormatTag
FormatTag.Formatter
 
Field Summary
 
Fields inherited from class com.bea.wlw.netui.tags.html.FormatTag
pattern, patternValue
 
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
FormatDate()
           
 
Method Summary
 int doStartTag()
          Create the internal Formatter instance and perform the formatting.
 String getStringInputPattern()
           
 String getTagName()
          Return the name of the Tag.
protected  void localRelease()
          Release any acquired resources.
 void setStringInputPattern(String pattern)
          Set the pattern to use to convert a String value into a date.
 
Methods inherited from class com.bea.wlw.netui.tags.html.FormatTag
getCountry, getLanguage, getLocale, getPattern, setCountry, setLanguage, setPattern
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, filter, formatErrorString, formatString, getAttribute, getErrorsReport, getExpressionEvaluator, getJavaScriptUtils, getNearestForm, getNextId, getQualifiedBundleName, getScriptReporter, getUserLocale, hasErrors, isExpression, prepForRendering, registerAttribute, registerError, registerTagError, release, removeAttribute, renderAttribute, renderAttributes, reportErrors, rewriteName, setPageContext, updateExpression, write
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doEndTag, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setParent
 

Constructor Detail

FormatDate

public FormatDate()
Method Detail

getTagName

public String getTagName()
Return the name of the Tag.

Specified by:
getTagName in class AbstractBaseTag

setStringInputPattern

public void setStringInputPattern(String pattern)
Set the pattern to use to convert a String value into a date. This will be used before the common formats.

Parameters:
pattern - the pattern representing the string input
Beadoc.attributedescription:
The pattern used to convert a String value into a date.
Beadoc.attributesyntaxvalue:
string_stringInputPattern
Beadoc.databindable:
Read Only

getStringInputPattern

public String getStringInputPattern()

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Create the internal Formatter instance and perform the formatting.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class FormatTag
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

localRelease

protected void localRelease()
Release any acquired resources.

Overrides:
localRelease in class FormatTag

BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.