HerrB, if you're using a DateBox you can pretty easily get the
behavior you're after by providing your own implementation of the
DateBox.Format interface to the DateBox constructor.  Your
implementation can pretty much just be a simple wrapper around the
Default one that adjusts the century to be 2000 when it's something
like 10.  It might be nice if the DefaultFormat had a setting like
(http://download.oracle.com/javase/7/docs/api/java/text/
SimpleDateFormat.html#set2DigitYearStart%28java.util.Date%29), but
it's pretty easy to work around the lack of that method.

On Dec 1, 11:53 am, John Tamplin <j...@google.com> wrote:
> On Wed, Dec 1, 2010 at 11:50 AM, HerrB92 <herr...@googlemail.com> wrote:
> > Err, yes ... I don't ever want a 2-digit year, also.
>
> > I have people, that enter "10" and expect to get "2010". Currently,
> > you will get "0010" (with a "yyyy" pattern).
>
> > But I think, I get the point: If there is textfield and a user enters
> > 1.1.10 and default date parsing is used (pattern "dd.MM.yyyy"), you
> > will get a valid date object - 10 years AC. My request would mean,
> > that if .format() is applied to that date, that the century is
> > replaced by the guessed century, if the given century equals "00".
>
> My point is that you want to fix that at the point the date is entered, not
> to just display the date differently, since many other things will depend on
> the year being correct.
>
> Ie, Date d = fixMissingCentury(dtf.parse(dateField));
>
> where fixMissingCentury detects a first-century year and changes it
> according to your needs.
>
> --
> John A. Tamplin
> Software Engineer (GWT), Google

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to