You've not been forgotten. :) You're correct that this is not
currently supported. This only adds a simple method to a single
tool's VTL API and thus would not impede any forthcoming long-wished
for 2.0 release (at least in my book). Go for it.
One question, would it make sense to also add a:
public String toLocalizedPattern(String format) {
return toLocalizedPattern(format, getLocale());
}
for completeness? Or is that redundant?
On Wed, Oct 28, 2009 at 2:10 PM, Christopher Schultz
<[email protected]> wrote:
> All,
>
> I'm a big fan of DateTool and use it all the time in my Velocity
> templates. I recently had a revelation that, when providing hints to my
> users like "please format your date like this: MM/dd/yyyy", the date
> format itself is being read from the user's preferences and always in
> the SimpleDateFormat form (that is, using English-appropriate letters,
> etc.).
>
> SimpleDateFormat provides a simple way to localize a date format pattern
> into a non-English locale: toLocalizedPattern
>
> Basically, if you want to show MM/dd/yyyy in, say, German, you want to
> say "MM/tt/uuuu". Or, in French, it should be "MM/jj/aaaa". (Forget that
> MM/dd/yyyy is not exactly appropriate for my French and German friends,
> it's the representation of the pattern I'm worried about).
>
> Anyhow, it's not particularly convenient in a Velocity template to do
> the equivalent of this:
>
> new SimpleDateFormat(formatPattern, targetLocale).toLocalizedPattern()
>
> So, I'm proposing adding a method to DateTool:
>
> public String toLocalizedPattern(String dateFormat,
> Locale targetLocale)
>
> This method will pretty much just contain the above code.
>
> Any thoughts? I can add the method myself using my committer ninja
> skills (I'll bet you guys forgot about me, huh?) but I wanted to make
> sure that:
>
> 1. There wasn't a better way to do this, possibly already in existence
> 2. Nobody minded me adding such a method
> 3. The addition wouldn't disrupt a 2.0 tools release
>
> Thanks,
> -chris
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]