[threeten-dev] Pattern letters

Roger Riggs Roger.Riggs at oracle.com
Fri Dec 14 06:39:56 PST 2012


Reserving the characters is a good idea, adding them to the set of
characters that have to be explicitly quoted to be in the output string.

If the {} construct follows the format letter then it will require a 
lookahead
mechanism.  The syntax in java.util.Formatter puts the flags, width, 
precision,etc
*before* the conversion letter; making that consistent would make
it easier for developers.

$.02, Roger

On 12/14/2012 12:00 AM, Xueming Shen wrote:
> The pattern letter system is perfect when the format patterns are those
> year/month/day/hour/minute/second date/time elements, such as "yyyy"
> "MM dd" or "hh:mm:ss". But it starts to become somewhat strange when
> various different date/time elements get added and various "styles" get
> introduced, especially you have to list 9 letters for the nano world 
> and 5
> pattern letters but for "narrow form", sometime you will have to say 
> "what
> the...". Given my j.u.Formatter background, just wonder if it is 
> considerable
> to add some new syntax to the system, for example let's reserve the { 
> and }
> pair for various format flag, widht, precision an/or styles
>
> {[flags][width][.precision][narrow|short|full]]|
>
> narrow, short and full can be the reserved/accepted style name for text,
> for example E{short} for EEE, E{full} for EEEE and E{narrow} for EEEEE.
>
> Personally I feel H{2.2} looks better than the "ppH", and it's 
> attractive to have
> "-" as the left-justified flag:-)
>
> Understand it's a "culture" difference, and understand it's perfect to 
> count the
> number of pattern letters to have a real "feeling" how the output 
> might look
> like in most(?) of the cases, but just wonder it might be 
> convenient/cool to have
> a mixed culture pattern system. We have reserved [ and ] anyway and 
> it's just an
> addition.
>
> It's compatible with neither jdk's existing pattern, nor CLDR though:-)
>
> -Sherman

-- 
Thanks, Roger

Oracle Java Platform Group

Green Oracle <http://www.oracle.com/commitment> Oracle is committed to 
developing practices and products that help protect the environment



More information about the threeten-dev mailing list