Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: Release 1.5
-
Fix Version/s: Release 1.5
-
Component/s: None
-
Labels:None
Description
DateFormatter's formatPattern should be protected (or maybe a getter-method?). I want to extend DateFormatter to set the default format to "medium" (right now, init() defaults formatPattern to "short"), so I would like to do something like this:
public class GermanDateFormatter extends DateFormatter {
@Override
public void init() {
if (formatPattern == null) {
formatPattern = "medium";
}
super.init();
}
}
Or is there any better way to provide a formatPattern to the UrlBuilder#format() method?
The setFormatPattern(String) method always gets called before init(), even if the format pattern is null.
So you can override the default format pattern by intercepting the call to setFormatPattern:
public class GermanDateFormatter extends DateFormatter {
@Override
public void setFormatPattern(String formatPattern) { super.setFormatPattern(formatPattern == null ? "medium" : formatPattern); }
}