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
signature.asc
Description: OpenPGP digital signature