One way would be to just use what Paul already pointed out. You define one dateFormat property, and you use that same dateFormat property across all date Inserts.

But maybe you meant change the format without having to explicitly set it. In that case, you'll probably have to create your own DateInsert component that behaves as you want it to behave (default format).


Ryan Pan wrote:
All,
    Another question,If I wanna show all the date fields of whole page in
one format,is there any way to set Date format for one time but impact whole
page?

Thanks,
Ryan.

2005/12/16, Ryan Pan <[EMAIL PROTECTED]>:

all,
   It works.Thank you very much.
Ryan.

2005/12/16, Paul Cantrell <[EMAIL PROTECTED]>:

Right. Here's an example:

<span jwcid="@Insert" value="ognl:modificationTime"
format="ognl:dateFormat"/>

    public DateFormat getDateFormat() { return dateFormat; }
    private static final DateFormat dateFormat = new SimpleDateFormat
("yyyy-MMM-dd HH:mm");

I believe you can also inline the format in the page, though it's a
bit messier:

<span jwcid="@Insert" value="ognl:modificationTime" format="ognl:new
java.text.SimpleDateFormat('yyyy-MMM-dd HH:mm')"/>

(Warning: that second bit there is untested code.)

Cheers,

Paul

_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net

On Dec 15, 2005, at 6:30 AM, Prince John, Bedag wrote:


Hi Ryan,

Generally, in Java you can use (Simple)DateFormat to format dates.

In Tapestry, attach a DateTranslator to the field - you can define the
pattern as a parameter in your hivemodule.xml - or use the DatePicker,
passing a format parameter.

This sort of stuff is covered in Tapestry in Action, or in the user's
guide.

Best wishes

John

-----Original Message-----
From: Ryan Pan [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 15, 2005 11:26 AM
To: [email protected]
Subject: Is there any way to display a Date as text in the format I
wondering?

Hi all,
   I met a problem with displaying the a Date variable as text. I
even
can
not choose the display format of Date.
   For example: a Date variable "Date today = new Date()" which
will be
displayed as "Thu Dec 15 00:00:00 CST 2005" on front-page,while
what I wanna is "2005-12-15".
So I am looking forward a way to solve this problem.

Thank,
Ryan.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to