Github user lukaszlenart commented on a diff in the pull request: https://github.com/apache/struts/pull/141#discussion_r123429169 --- Diff: core/src/main/java/com/opensymphony/xwork2/conversion/impl/DateConverter.java --- @@ -48,7 +51,28 @@ public Object convertValue(Map<String, Object> context, Object target, Member me } } else if (java.util.Date.class == toType) { Date check; - DateFormat[] dfs = getDateFormats(locale); + + + // Add the user provided date format if any + final TextProvider tp = findProviderInStack((ValueStack) context.get(ActionContext.VALUE_STACK)); + SimpleDateFormat globalDateFormat = null; + + if (tp != null) { + String globalFormat = tp.getText(org.apache.struts2.components.Date.DATETAG_PROPERTY); + + // if tp.getText can not find the property then the + // returned string is the same as input = + // DATETAG_PROPERTY + if (globalFormat != null + && !org.apache.struts2.components.Date.DATETAG_PROPERTY.equals(globalFormat)) { + globalDateFormat = new SimpleDateFormat(globalFormat, locale); + } + } --- End diff -- Could you move this whole section into `getDateFormats` to avoid passing the `globalDateFormat` as a parameter? Also it would be good to extract this logic into a protected method to allow override, so the finally it should look like this: ```java DateFormat[] dfs = getDateFormats(globalDateFormat, locale); ... private DateFormat[] getDateFormats(Locale locale) { ... DateFormat globalDateFormat = getGlobalDateFormat(); ... } protected getGlobalDateFormat() { // your code here } ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org For additional commands, e-mail: dev-h...@struts.apache.org