org.chenillekit.tapestry.core.components.DateFormat

Formats a Date object with the given pattern. The given html tag sourrunds the formatted date value end the optional parameter bodyPosition shifts the tag body to the left or right side, or discarded it.

[JavaDoc]

Component Parameters

Name Type Flags Default Default Prefix Description
bodyPosition int NOT Allow Null 0 literal the eelement body position. may be : BODY_POS_NONE (default) / BODY_POS_LEFT / BODY_POS_RIGHT
pattern String NOT Allow Null yyyy-MM-dd literal the format pattern.
value java.util.Date Required, NOT Allow Null prop the date value.

Examples

this example describe how to use the DateFormat component.

MyPage.tml

                    
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
    <body>
        <h1>Hello Guys and Dolls</h1>

            <ul>
                <li>
                    Date with body on the left side:
                    <span t:type="ck/DateFormat" value="dateValue"
                            pattern="prop:patternDE" bodyPosition="1">today is </span>
                </li>
                <li>
                    Date with body on the right side:
                    <span t:type="ck/DateFormat" value="dateValue"
                            pattern="prop:patternUS" bodyPosition="2"> todays date</span>
                </li>
                <li>
                    Date with discarded body
                    <span t:type="ck/DateFormat" value="dateValue">without body</span>
                </li>
            </ul>

    </body>
</html>

                

MyPage.java

                    
public class MyPage
{
    @Property(write = false)
    private Date _dateValue;

    @Property(write = false)
    private String _patternUS = "dd/MM/yyyy";

    @Property(write = false)
    private String _patternDE = "dd.MM.yyyy";

    void setupRender()
    {
        _dateValue = new Date();
    }
}

                

Back to index