开发者

tapestry. output of Date

开发者 https://www.devze.com 2023-02-21 06:55 出处:网络
how to do? <t:output format=\"literal:dd.MM.yyyy\" value=\"myItem.a开发者_StackOverflowctivity.do_create_date\"/>

how to do?

<t:output format="literal:dd.MM.yyyy" value="myItem.a开发者_StackOverflowctivity.do_create_date"/>

I want to know how to format output of date?


What you have works (in Tapestry 5.2.4). What problem are you having or what more specifically are you trying to do? If you want to get the format from your Java class, here's are example snippets.

.java file:

private String format;
private Date date;

public void setupRender() {
    // just an example
    format = "dd.MM.yyyy";
    date = new Date();
}

public String getFormat() {
    return format;
}

public Date getDate() {
    return date;
}

.tml file:

<t:output format="format" value="date" />


I've found that most apps have specific, uniform ways to format dates; I usually create a OutputDate component that encapsulates formatting and other concerns.


page template:

<t:output format="format" value="myItem.activity.do_create_date"/>

page class:

private final String format = "dd.MM.yyyy";

public Format getFormat()
{
    return new SimpleDateFormat(format);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号