Hi!
>
> I have a user who loves to enter the date as MM/dd/YY ignoring the
> help text
>
> But the expected is MM/dd/yyyy
>
> So when he enters 12/01/06 ….
>
Might not be much of help, but I implemented a rather complicated
converter ... well not that complicated, just uses tons of simple date
formats ... to allow the user to enter virtually any date. e.g.
mm/dd/yyyy, mm/dd/yy, mm/dd or just dd for the first two cases I use the
fact that you can have a DateFormat m/d/y and java is smart enough to
parse it right.

        SimpleDateFormat sdf = new SimpleDateFormat("M/d/y", Locale.US);
        System.err.println(sdf.parse("12/01/06"));
        System.err.println(sdf.parse("12/01/2006"));

With some tricky string operations you can create the patterns in a
locale sensitive way.

Ciao,
Mario

Reply via email to