Hi, reading the javadoc, I could note that org.apache.wicket.extensions.markup.html.form.DateTextField gets the Locale if the developer does not supply one. But that it is not true, once that the simplest constructor, DateTextField(String wicketId), calls the "most advanced" DataTextField(wicketId, null, DEFAULT_PATTERN), with DEFAULT_PATTERN = "MM/dd/yy". In order to fix that, what is the best approach? Analyzing the code, getTextFormat() returns the pattern, and it is used only by DatePicker. By the other hand, the code changed could be minimized querying the DateFormat object with user's locale, cast it for SimpleDateFormat and call toPattern for get the pattern. Javadoc of DateFormat writes that is safe for most languages, so it is an aproach. If this call fails, wicket could fallback to DEFAULT_PATTERN.
Is this ok? How could it be fixed?
39a40,43 > * Note that for use users locale, <code>java.text.DateFormat.getDateInstance()</code> must > * return a <code>java.text.SimpleDateFormat</code> object, otherwise a pattern "MM/dd/yy" > * will be used. > * 74c78 < this(id, null, DEFAULT_PATTERN); --- > this(id, null, null); 90c94 < this(id, model, DEFAULT_PATTERN); --- > this(id, model, null); 123c127,144 < this.datePattern = datePattern; --- > if (datePattern == null) > { > DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT,getLocale()); > //DateFormat writes that you can expect the instanceof below for most > //countries > if (df instanceof SimpleDateFormat) { > this.datePattern = ((SimpleDateFormat) df).toPattern(); > } > else > { > this.datePattern = DEFAULT_PATTERN; > } > } > else > { > this.datePattern = datePattern; > } >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]