Search in sources :

Example 16 with FormatStrings

use of com.haulmont.chile.core.datatypes.FormatStrings in project cuba by cuba-platform.

the class SiteSettings method getFreeMarkerSettings.

public Properties getFreeMarkerSettings() {
    Configuration configuration = AppBeans.get(Configuration.NAME);
    GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
    Map<String, Locale> availableLocales = globalConfig.getAvailableLocales();
    if (availableLocales.isEmpty())
        throw new IllegalStateException("Property cuba.availableLocales is not configured");
    Locale locale = availableLocales.values().iterator().next();
    FormatStrings formatStrings = Datatypes.getFormatStrings(locale);
    final Properties freemarkerSettings = new Properties();
    freemarkerSettings.setProperty("number_format", "#");
    freemarkerSettings.setProperty("datetime_format", formatStrings.getDateTimeFormat());
    freemarkerSettings.setProperty("date_format", formatStrings.getDateFormat());
    freemarkerSettings.setProperty("template_exception_handler", "rethrow");
    return freemarkerSettings;
}
Also used : Locale(java.util.Locale) Configuration(com.haulmont.cuba.core.global.Configuration) GlobalConfig(com.haulmont.cuba.core.global.GlobalConfig) FormatStrings(com.haulmont.chile.core.datatypes.FormatStrings) Properties(java.util.Properties)

Aggregations

FormatStrings (com.haulmont.chile.core.datatypes.FormatStrings)16 FormatStringsRegistry (com.haulmont.chile.core.datatypes.FormatStringsRegistry)13 DecimalFormat (java.text.DecimalFormat)10 DecimalFormatSymbols (java.text.DecimalFormatSymbols)9 NumberFormat (java.text.NumberFormat)7 DateFormat (java.text.DateFormat)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Datatype (com.haulmont.chile.core.datatypes.Datatype)1 Configuration (com.haulmont.cuba.core.global.Configuration)1 GlobalConfig (com.haulmont.cuba.core.global.GlobalConfig)1 BigDecimal (java.math.BigDecimal)1 Locale (java.util.Locale)1 Properties (java.util.Properties)1 PostConstruct (javax.annotation.PostConstruct)1