本文整理汇总了Java中freemarker.core.Environment.setTimeZone方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.setTimeZone方法的具体用法?Java Environment.setTimeZone怎么用?Java Environment.setTimeZone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freemarker.core.Environment
的用法示例。
在下文中一共展示了Environment.setTimeZone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyUserSettings
import freemarker.core.Environment; //导入方法依赖的package包/类
/**
* Apply user settings to an Environment instance.
* @param env An Environment instance
* @param context The context Map containing the user settings
*/
public static void applyUserSettings(Environment env, Map<String, Object> context) throws TemplateException {
Locale locale = (Locale) context.get("locale");
if (locale == null) {
locale = Locale.getDefault();
}
env.setLocale(locale);
TimeZone timeZone = (TimeZone) context.get("timeZone");
if (timeZone == null) {
timeZone = TimeZone.getDefault();
}
env.setTimeZone(timeZone);
}
示例2: setupEnvironment
import freemarker.core.Environment; //导入方法依赖的package包/类
protected void setupEnvironment(Writer writer, FreemarkerSectionResult result, Environment environment)
{
environment.setLocale(CurrentLocale.getLocale());
environment.setTimeZone(CurrentTimeZone.get());
environment.setURLEscapingCharset("UTF-8");
}