What about a component like this:
public class DateFormatter
{
@Inject private Messages _messages;
@Parameter(required = true, defaultPrefix = "prop") private Date _date;
@Parameter(required = false, defaultPrefix = "literal") private
String _format;
boolean beginRender(final MarkupWriter writer)
{
if (null != _date) {
try {
if (null == _format) {
_format = "yyyy-MM-dd hh:mm:ss";
}
final SimpleDateFormat sdf = new SimpleDateFormat(_format);
writer.writeRaw(sdf.format(_date));
} catch (final Exception e) {
writer.writeRaw(_date.toString());
}
}
return false;
}
}
Usage in TML:
<t:DateFormatter date="yourDateMemberHere" format="${message:format_TIME}"/>
Using "message" allows you to configure it easily without hardcoding it.
Therefore in your global message catalog you can define:
App_de.properties:
...
format_DATE_TIME = dd.MM.yyyy - HH:mm:ss
format_DATE = dd.MM.yyyy
format_TIME = HH:mm:ss
...
In the example above your date will only render the time portion
Jens
Am 14.05.14 19:59, schrieb Lance Java:
I'm not sure how you have assumed that tapestry knows how understand a
"format:" binding prefix. Certainly none of the tapestry documentation
mentions it?
The simple solution is to provide a getter for the formatted date String.
If you really want a "format:" binding prefix, you can create a custom
binding prefix.
On 14 May 2014 18:31, "Aristedes Maniatis" <a...@ish.com.au> wrote:
I understand that I can do this in the tml:
<span itemprop="startDate"><t:output value="someDate"
format="literal:YYYY-MM-DD hh:mm:ss 'UTC' Z"></span>
But I want to put the value into an attribute to suit a Google schema
microformat, like this:
<abbr itemprop="startDate" content="${format:date=YYYY-MM-DD hh:mm:ss
'UTC' Z,someDate}" title="">
This does not work. What am I missing here?
Ari Maniatis
--
-------------------------->
Aristedes Maniatis
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org