use of freemarker.core.AliasTemplateNumberFormatFactory in project freemarker by apache.
the class CustomFormatsExample method aliases2.
@Test
public void aliases2() throws IOException, TemplateException {
Configuration cfg = getConfiguration();
Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();
customNumberFormats.put("base", BaseNTemplateNumberFormatFactory.INSTANCE);
customNumberFormats.put("oct", new AliasTemplateNumberFormatFactory("@base 8"));
cfg.setCustomNumberFormats(customNumberFormats);
assertOutputForNamed("CustomFormatsExample-alias2.ftlh");
}
use of freemarker.core.AliasTemplateNumberFormatFactory in project freemarker by apache.
the class CustomFormatsExample method aliases1.
@Test
public void aliases1() throws IOException, TemplateException {
Configuration cfg = getConfiguration();
Map<String, TemplateNumberFormatFactory> customNumberFormats = new HashMap<String, TemplateNumberFormatFactory>();
customNumberFormats.put("price", new AliasTemplateNumberFormatFactory(",000.00"));
customNumberFormats.put("weight", new AliasTemplateNumberFormatFactory("0.##;; roundingMode=halfUp"));
cfg.setCustomNumberFormats(customNumberFormats);
Map<String, TemplateDateFormatFactory> customDateFormats = new HashMap<String, TemplateDateFormatFactory>();
customDateFormats.put("fileDate", new AliasTemplateDateFormatFactory("dd/MMM/yy hh:mm a"));
customDateFormats.put("logEventTime", new AliasTemplateDateFormatFactory("iso ms u"));
cfg.setCustomDateFormats(customDateFormats);
addToDataModel("p", 10000);
addToDataModel("w", new BigDecimal("10.305"));
addToDataModel("fd", new Date(1450904944213L));
addToDataModel("let", new Date(1450904944213L));
assertOutputForNamed("CustomFormatsExample-alias1.ftlh");
}
Aggregations