package com.xfyre.tapestry5.xtensions.components;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.annotations.Parameter;

/**
 * Convenience component for formatting dates
 * @author xfire
 *
 */
public class FormatDate {
    /**
     * Date value
     */
    @Parameter(required=true,defaultPrefix=BindingConstants.PROP)
    private Date date;
    
    /**
     * Format string
     */
    @Parameter(required=true,defaultPrefix=BindingConstants.LITERAL)
    private String format;
    
    void beginRender ( MarkupWriter writer ) {
        if ( date == null ) {
            writer.writeRaw ( "" );
        } else {
            DateFormat df = new SimpleDateFormat ( format );
            writer.writeRaw ( df.format ( date ) );
        }
    }
}

@@ -270,16 +270,123 @@
 rameter;
+%0Aimport org.apache.tapestry5.ioc.annotations.Inject;%0Aimport org.apache.tapestry5.services.PersistentLocale;
 %0A%0A/**%0A *
@@ -602,20 +602,16 @@
 e date;%0A
-    
 %0A    /**
@@ -656,35 +656,36 @@
 ameter(required=
-tru
+fals
 e,defaultPrefix=
@@ -737,20 +737,76 @@
 format;%0A
+%0A
     
+@Inject%0A    private PersistentLocale persistentLocale;%0A
 %0A    voi
@@ -955,16 +955,128 @@
 mat df =
+ format == null ?%0A                    DateFormat.getDateInstance ( DateFormat.SHORT, persistentLocale.get () ) :
  new Sim

Allow persistent locale-based formatting for DateFormat