[ https://issues.apache.org/jira/browse/FREEMARKER-31?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15416704#comment-15416704 ]
Michał Sobkiewicz commented on FREEMARKER-31: --------------------------------------------- Hi, Daniel! This is definitely an acceptable compromise! Despite being a little more verbose, proposed solution gives even more power than expected. I wish i knew about _object builder expressions_ before. I see now that solution was two clicks ahead, at {{Configuration#setSetting}} documentation. Javadoc is indeed a great place to describe every supported option, it was surprising however to find there a different _kind_ of options (expressions instead of literals). Nothing in the examples suggested that it's going to be possible. Because I was convinced that the only thing I can find is more "simple", "default" and "square_bracket"-like constants, I hadn't checked javadoc. Please consider adding at least one example that uses expressions at [http://freemarker.org/docs/pgui_config_settings.html] to indicate that there is more power to discover. Thank you for your help! > Default date type as setting > ---------------------------- > > Key: FREEMARKER-31 > URL: https://issues.apache.org/jira/browse/FREEMARKER-31 > Project: Apache Freemarker > Issue Type: Improvement > Components: engine > Reporter: Michał Sobkiewicz > > To set default date type, one have to use > {{freemarker.ext.beans.BeansWrapperConfiguration#setDefaultDateType(int)}} or > {{freemarker.ext.beans.BeansWrapper#setDefaultDateType(int)}}. It would be > convenient to set {{defaultDateType}} by using property. > {{freemarker.core.Configurable#setSetting(String,String)}} recognises date, > time and number formats. It even lets you choose object wrapper! At the same > time you can't specify how to deal with not-so-exotic {{java.util.Date}}. > I'd like to set default date type just as I can set exception handling. I > know that {{defaultDateType}} attribute would have to be moved to > {{freemarker.template.Configuration}}, but I'm convinced that this is the > right thing to do. > If it makes sense to talk about "default date type" (which seems to be true > as {{defaultDateType}} property already exists), it may be also valid to > expect a little more accessible way to set this up. With no customized bean > wrapper, without adding a bit redundant "?date" after each... well.. date, > you end up with > {{freemarker.core.UnknownDateTypeFormattingUnsupportedException}}. > Sample settings below: > {quote} > locale=en_US > dateFormat=yyyy-MM-dd > numberFormat=0.00 > logTemplateExceptions=false > templateExceptionHandler=rethrow > defaultDateType=date > {quote} > I truly believe that the last one should be supported. -- This message was sent by Atlassian JIRA (v6.3.4#6332)