@Override protected DateTimeFormatter getDateTimeFormatter(FormatStrings formatStrings, Locale locale) { return DateTimeFormatter.ofPattern(formatStrings.getDateTimeFormat(), locale); }
@Override protected DateTimeFormatter getDateTimeFormatter(FormatStrings formatStrings, Locale locale) { return DateTimeFormatter.ofPattern(formatStrings.getDateTimeFormat(), locale).withZone(ZoneId.systemDefault()); }
@Nullable public Date parse(@Nullable String value, Locale locale, TimeZone timeZone) throws ParseException { if (StringUtils.isBlank(value)) { return null; } FormatStrings formatStrings = AppBeans.get(FormatStringsRegistry.class).getFormatStrings(locale); if (formatStrings == null) { return parse(value); } DateFormat format = new SimpleDateFormat(formatStrings.getDateTimeFormat()); if (timeZone != null) { format.setTimeZone(timeZone); } return format.parse(value.trim()); }
@Override public String format(@Nullable Object value, Locale locale, TimeZone timeZone) { if (value == null) { return ""; } FormatStrings formatStrings = AppBeans.get(FormatStringsRegistry.class).getFormatStrings(locale); if (formatStrings == null) { return format(value); } DateFormat format = new SimpleDateFormat(formatStrings.getDateTimeFormat()); if (timeZone != null) { format.setTimeZone(timeZone); } return format.format(value); }
public Properties getFreeMarkerSettings() { 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 = formatStringsRegistry.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; } }
break; case "DATETIME": format = formatStrings.getDateTimeFormat(); break; default: