use of freemarker.template.Configuration in project freemarker by apache.
the class SQLTimeZoneTest method testWithDefaultTZAndNullSQL.
@Test
public void testWithDefaultTZAndNullSQL() throws Exception {
TimeZone prevSysDefTz = TimeZone.getDefault();
TimeZone.setDefault(GMT_P02);
try {
Configuration cfg = getConfiguration();
cfg.unsetTimeZone();
assertNull(cfg.getSQLDateAndTimeTimeZone());
assertEquals(TimeZone.getDefault(), cfg.getTimeZone());
assertOutput(FTL, OUTPUT_BEFORE_SETTING_GMT_CFG_GMT2 + OUTPUT_AFTER_SETTING_GMT_CFG_SQL_SAME);
} finally {
TimeZone.setDefault(prevSysDefTz);
}
}
use of freemarker.template.Configuration in project freemarker by apache.
the class SQLTimeZoneTest method testCacheFlushings.
@Test
public void testCacheFlushings() throws Exception {
Configuration cfg = getConfiguration();
cfg.setTimeZone(DateUtil.UTC);
cfg.setDateFormat("yyyy-MM-dd E");
cfg.setTimeFormat("HH:mm:ss E");
cfg.setDateTimeFormat("yyyy-MM-dd'T'HH:mm:ss E");
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting locale='hu'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-11 Fri, 10:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-11 P, 10:30:05 Cs, 2014-07-12T10:30:05 Szo, 2014-07-12T10:30:05 Szo, 2014-07-12 Szo, 10:30:05 Szo\n");
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting date_format='yyyy-MM-dd'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-11 Fri, 10:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-11, 10:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12, 10:30:05 Sat\n");
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting time_format='HH:mm:ss'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-11 Fri, 10:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-11 Fri, 10:30:05, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05\n");
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting datetime_format='yyyy-MM-dd\\'T\\'HH:mm:ss'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-11 Fri, 10:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-11 Fri, 10:30:05 Thu, 2014-07-12T10:30:05, 2014-07-12T10:30:05, 2014-07-12 Sat, 10:30:05 Sat\n");
cfg.setSQLDateAndTimeTimeZone(GMT_P02);
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting locale='hu'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-12 Sat, 12:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-12 Szo, 12:30:05 Cs, 2014-07-12T10:30:05 Szo, 2014-07-12T10:30:05 Szo, 2014-07-12 Szo, 10:30:05 Szo\n");
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting date_format='yyyy-MM-dd'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-12 Sat, 12:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-12, 12:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12, 10:30:05 Sat\n");
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting time_format='HH:mm:ss'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-12 Sat, 12:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-12 Sat, 12:30:05, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05\n");
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n" + "<#setting datetime_format='yyyy-MM-dd\\'T\\'HH:mm:ss'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}, ${javaDate?date}, ${javaDate?time}\n", "2014-07-12 Sat, 12:30:05 Thu, 2014-07-12T10:30:05 Sat, 2014-07-12T10:30:05 Sat, 2014-07-12 Sat, 10:30:05 Sat\n" + "2014-07-12 Sat, 12:30:05 Thu, 2014-07-12T10:30:05, 2014-07-12T10:30:05, 2014-07-12 Sat, 10:30:05 Sat\n");
}
use of freemarker.template.Configuration in project freemarker by apache.
the class SQLTimeZoneTest method testWithGMT2AndNullSQL.
@Test
public void testWithGMT2AndNullSQL() throws Exception {
Configuration cfg = getConfiguration();
assertNull(cfg.getSQLDateAndTimeTimeZone());
cfg.setTimeZone(TimeZone.getTimeZone("GMT+02"));
assertOutput(FTL, OUTPUT_BEFORE_SETTING_GMT_CFG_GMT2 + OUTPUT_AFTER_SETTING_GMT_CFG_SQL_SAME);
}
use of freemarker.template.Configuration in project freemarker by apache.
the class SQLTimeZoneTest method testChangeSettingInTemplate.
@Test
public void testChangeSettingInTemplate() throws Exception {
Configuration cfg = getConfiguration();
cfg.setTimeZone(DateUtil.UTC);
assertNull(cfg.getSQLDateAndTimeTimeZone());
assertOutput("${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting sql_date_and_time_time_zone='GMT+02'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting sql_date_and_time_time_zone='null'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting time_zone='GMT+03'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting sql_date_and_time_time_zone='GMT+02'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting sql_date_and_time_time_zone='GMT-11'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting date_format='xs fz'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting time_format='xs fz'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n" + "<#setting datetime_format='iso m'>\n" + "${sqlDate}, ${sqlTime}, ${sqlTimestamp}, ${javaDate?datetime}\n", "2014-07-11, 10:30:05, 2014-07-12T10:30:05, 2014-07-12T10:30:05\n" + "2014-07-12, 12:30:05, 2014-07-12T10:30:05, 2014-07-12T10:30:05\n" + "2014-07-11, 10:30:05, 2014-07-12T10:30:05, 2014-07-12T10:30:05\n" + "2014-07-12, 13:30:05, 2014-07-12T13:30:05, 2014-07-12T13:30:05\n" + "2014-07-12, 12:30:05, 2014-07-12T13:30:05, 2014-07-12T13:30:05\n" + "2014-07-11, 23:30:05, 2014-07-12T13:30:05, 2014-07-12T13:30:05\n" + "2014-07-11-11:00, 23:30:05, 2014-07-12T13:30:05, 2014-07-12T13:30:05\n" + "2014-07-11-11:00, 23:30:05-11:00, 2014-07-12T13:30:05, 2014-07-12T13:30:05\n" + "2014-07-11-11:00, 23:30:05-11:00, 2014-07-12T13:30+03:00, 2014-07-12T13:30+03:00\n");
}
use of freemarker.template.Configuration in project freemarker by apache.
the class SQLTimeZoneTest method createConfiguration.
@Override
protected Configuration createConfiguration() {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_21);
cfg.setLocale(Locale.US);
cfg.setDateFormat("yyyy-MM-dd");
cfg.setTimeFormat("HH:mm:ss");
cfg.setDateTimeFormat("yyyy-MM-dd'T'HH:mm:ss");
return cfg;
}
Aggregations