Example usage for java.util TimeZone getOffset

List of usage examples for java.util TimeZone getOffset

Introduction

In this page you can find the example usage for java.util TimeZone getOffset.

Prototype

public int getOffset(long date) 

Source Link

Document

Returns the offset of this time zone from UTC at the specified date.

Usage

From source file:DateTime.java

public DateTime(Date date, TimeZone zone) {
    long value = date.getTime();
    dateOnly = false;//from  w  w  w  . j a  va  2  s .co  m
    this.value = value;
    tzShift = zone.getOffset(value) / 60000;
}

From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.AppMessageHandlerMorpheuz.java

@Override
public GBDeviceEvent[] handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
    int ctrl_message = 0;
    GBDeviceEventSleepMonitorResult sleepMonitorResult = null;

    for (Pair<Integer, Object> pair : pairs) {
        if (Objects.equals(pair.first, keyTransmit)) {
            sleepMonitorResult = new GBDeviceEventSleepMonitorResult();
            sleepMonitorResult.smartalarm_from = smartalarm_from;
            sleepMonitorResult.smartalarm_to = smartalarm_to;
            sleepMonitorResult.alarm_gone_off = alarm_gone_off;
            sleepMonitorResult.recording_base_timestamp = recording_base_timestamp;
            ctrl_message |= CTRL_TRANSMIT_DONE;
        } else if (pair.first.equals(keyGoneoff)) {
            alarm_gone_off = (int) pair.second;
            LOG.info("got gone off: " + alarm_gone_off / 60 + ":" + alarm_gone_off % 60);
            ctrl_message |= CTRL_DO_NEXT | CTRL_GONEOFF_DONE;
        } else if (pair.first.equals(keyPoint)) {
            if (recording_base_timestamp == -1) {
                // we have no base timestamp but received points, stop this
                ctrl_message = CTRL_VERSION_DONE | CTRL_GONEOFF_DONE | CTRL_TRANSMIT_DONE | CTRL_SET_LAST_SENT;
            } else {
                int index = ((int) pair.second >> 16);
                int intensity = ((int) pair.second & 0xffff);
                LOG.info("got point:" + index + " " + intensity);
                if (index >= 0) {
                    try (DBHandler db = GBApplication.acquireDB()) {
                        Long userId = DBHelper.getUser(db.getDaoSession()).getId();
                        Long deviceId = DBHelper.getDevice(getDevice(), db.getDaoSession()).getId();
                        PebbleMorpheuzSampleProvider sampleProvider = new PebbleMorpheuzSampleProvider(
                                getDevice(), db.getDaoSession());
                        PebbleMorpheuzSample sample = new PebbleMorpheuzSample(
                                recording_base_timestamp + index * 600, deviceId, userId, intensity);
                        sample.setProvider(sampleProvider);
                        sampleProvider.addGBActivitySample(sample);
                    } catch (Exception e) {
                        LOG.error("Error acquiring database", e);
                    }/* www .  ja  va  2  s  .co m*/
                }

                ctrl_message |= CTRL_SET_LAST_SENT | CTRL_DO_NEXT;
            }
        } else if (pair.first.equals(keyFrom)) {
            smartalarm_from = (int) pair.second;
            LOG.info("got from: " + smartalarm_from / 60 + ":" + smartalarm_from % 60);
            ctrl_message |= CTRL_SET_LAST_SENT | CTRL_DO_NEXT;
        } else if (pair.first.equals(keyTo)) {
            smartalarm_to = (int) pair.second;
            LOG.info("got to: " + smartalarm_to / 60 + ":" + smartalarm_to % 60);
            ctrl_message |= CTRL_SET_LAST_SENT | CTRL_DO_NEXT;
        } else if (pair.first.equals(keyVersion)) {
            int version = (int) pair.second;
            LOG.info("got version: " + ((float) version / 10.0f));
            ctrl_message |= CTRL_VERSION_DONE;
        } else if (pair.first.equals(keyBase)) {// fix timestamp
            TimeZone tz = SimpleTimeZone.getDefault();
            recording_base_timestamp = (int) pair.second - (tz.getOffset(System.currentTimeMillis())) / 1000;
            LOG.info("got base: " + recording_base_timestamp);
            ctrl_message |= CTRL_SET_LAST_SENT | CTRL_DO_NEXT;
        } else if (pair.first.equals(keyAutoReset)) {
            ctrl_message |= CTRL_SET_LAST_SENT | CTRL_DO_NEXT;
        } else if (pair.first.equals(keySnoozes)) {
            ctrl_message |= CTRL_SNOOZES_DONE | CTRL_DO_NEXT;
        } else if (pair.first.equals(keyFault)) {
            LOG.info("fault code: " + (int) pair.second);
            ctrl_message |= CTRL_DO_NEXT;
        } else {
            LOG.info("unhandled key: " + pair.first);
        }
    }

    // always ack
    GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes();
    sendBytesAck.encodedBytes = mPebbleProtocol.encodeApplicationMessageAck(mUUID, mPebbleProtocol.last_id);

    // sometimes send control message
    GBDeviceEventSendBytes sendBytesCtrl = null;
    if (ctrl_message > 0) {
        sendBytesCtrl = new GBDeviceEventSendBytes();
        sendBytesCtrl.encodedBytes = encodeMorpheuzMessage(keyCtrl, ctrl_message);
    }

    // ctrl and sleep monitor might be null, thats okay
    return new GBDeviceEvent[] { sendBytesAck, sendBytesCtrl, sleepMonitorResult };
}

From source file:com.haulmont.cuba.core.global.TimeZones.java

/**
 * Not recommended for use. Will be removed in a future version
 * Converts date between time zones.//from w w  w. j a  va 2  s .com
 *
 * @param srcDate       date
 * @param srcTimeZone   source time zone
 * @param dstTimeZone   destination time zone
 * @return              date in destination time zone, or null if the source date is null
 */
@Nullable
@Deprecated
public Date convert(@Nullable Date srcDate, TimeZone srcTimeZone, TimeZone dstTimeZone) {
    if (srcDate == null)
        return null;
    Preconditions.checkNotNullArgument(srcTimeZone, "srcTimeZone is null");
    Preconditions.checkNotNullArgument(dstTimeZone, "dstTimeZone is null");
    int srcOffset = srcTimeZone.getOffset(srcDate.getTime());
    int dstOffset = dstTimeZone.getOffset(srcDate.getTime());
    return new Date(srcDate.getTime() - srcOffset + dstOffset);
}

From source file:org.jspresso.framework.application.startup.remote.RemoteStartup.java

/**
 * Starts the remote application passing it the client locale.
 *
 * @param startCommand/*from ww w  .  jav a  2  s  . c  om*/
 *          the start command wrapping the various client start parameters.
 * @return the commands to be executed by the client peer on startup.
 */
public List<RemoteCommand> start(RemoteStartCommand startCommand) {
    try {
        Locale locale = LocaleUtils.toLocale(startCommand.getLanguage());
        IFrontendController<RComponent, RIcon, RAction> controller = getFrontendController();
        if (!dupSessionNotifiedOnce && isDupSessionDetectionEnabled() && controller != null
                && controller.isStarted()) {
            dupSessionNotifiedOnce = true;
            RemoteMessageCommand errorMessage = createErrorMessageCommand();
            errorMessage.setMessage(controller.getTranslation("session.dup",
                    new Object[] { controller.getI18nName(controller, locale) }, locale));
            // Do not return the singleton list directly since subclasses might add commands to it.
            return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage));
        }
        dupSessionNotifiedOnce = false;
        setStartupLocale(locale);
        TimeZone serverTimeZone = TimeZone.getDefault();
        int currentOffset = serverTimeZone.getOffset(System.currentTimeMillis());
        TimeZone clientTz = null;
        if (currentOffset == startCommand.getTimezoneOffset()) {
            clientTz = serverTimeZone;
        } else {
            String[] availableIds = TimeZone.getAvailableIDs(startCommand.getTimezoneOffset());
            if (availableIds.length > 0) {
                for (int i = 0; i < availableIds.length && clientTz == null; i++) {
                    TimeZone tz = TimeZone.getTimeZone(availableIds[i]);
                    if (tz.useDaylightTime() == serverTimeZone.useDaylightTime()) {
                        clientTz = tz;
                    }
                }
                if (clientTz == null) {
                    clientTz = TimeZone.getTimeZone(availableIds[0]);
                }
            } else {
                clientTz = TimeZone.getDefault();
            }
        }
        setClientTimeZone(clientTz);
        start();
        controller = getFrontendController();
        if (startCommand.getVersion() != null && !isClientVersionCompatible(startCommand.getVersion())) {
            RemoteMessageCommand errorMessage = createErrorMessageCommand();
            assert controller != null;
            errorMessage.setMessage(controller.getTranslation("incompatible.client.version",
                    new Object[] { startCommand.getVersion(), Build.getJspressoVersion() }, locale));
            // Do not return the singleton list directly since subclasses might add commands to it.
            return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage));
        }
        try {
            return handleCommands(Collections.singletonList((RemoteCommand) startCommand));
        } catch (Throwable ex) {
            if (controller != null) {
                controller.traceUnexpectedException(ex);
            }
            return Collections.emptyList();
        }
    } catch (RuntimeException ex) {
        LOG.error("An unexpected error occurred while starting the server.", ex);
        RemoteMessageCommand errorMessage = createErrorMessageCommand();
        errorMessage.setMessage(
                "An unexpected error occurred while starting the server. Please contact the application manager.");
        // Do not return the singleton list directly since subclasses might add commands to it.
        return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage));
    }
}

From source file:com.scoreminion.GameAdapter.java

/**
 * Converts UTC date string to localized date string.
 *
 * @param utcDateStr the date string returned from the Scores API
 * @return the localized date string//from   w ww  .jav  a 2  s .  co  m
 */
private String convertDateString(String utcDateStr) {
    Calendar rightNow = Calendar.getInstance();
    TimeZone timeZone = rightNow.getTimeZone();
    SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.US);
    Date date = dateFormat.parse(utcDateStr, new ParsePosition(DATE_PARSE_POSITION_OFFSET));
    Date adjustedDate = new Date(date.getTime() + timeZone.getOffset(rightNow.getTimeInMillis()));

    return dateFormat.format(adjustedDate);
}

From source file:de.micromata.genome.gwiki.controls.GWikiRegisterUserActionBean.java

protected boolean doRegister() {
    if (StringUtils.isBlank(catchaInput) == true) {
        wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.nocatcha", "catchaInput");
        return false;
    }// www .  jav  a 2 s . c  o  m
    if (checkCatcha() == false) {
        wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.wrongcatcha", "catchaInput");
        return false;
    }
    user = StringUtils.trim(user);
    if (StringUtils.isBlank(user) == true) {
        wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.userempty", "user");
        return false;
    }
    email = StringUtils.trim(email);
    if (StringUtils.isBlank(email) == true) {
        wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.emailempty", "email");
        return false;
    }
    if (checkEmail(email) == false) {
        wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.emailnotvalid", "email");
        return false;
    }
    if (doubleOptIn == false) {
        if (StringUtils.isBlank(pass) == true) {
            wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.passempty", "pass");
            pass2 = "";
            return false;
        }
        if (pass.equals(pass2) == false) {
            wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.passnotequal", "pass");
            return false;
        }
    } else {
        pass = GWikiLoginActionBean.genPassword();
    }

    GWikiAuthorizationExt authExt = (GWikiAuthorizationExt) wikiContext.getWikiWeb().getAuthorization();
    if (authExt.hasUser(wikiContext, user) == true) {
        wikiContext.addValidationFieldError("gwiki.page.admin.RegisterUser.message.userexists", "user");
        return false;
    }
    if (GWikiSimpleUserAuthorization.rankPasswort(pass) < 1000) {
        wikiContext.addValidationFieldError("gwiki.profile.message.password_too_simple", "pass");
        return false;
    }
    String cp = GWikiSimpleUserAuthorization.encrypt(pass);
    GWikiProps props = new GWikiProps();
    GWikiElement registeredUser = wikiContext.getWikiWeb().findElement("admin/user/registereduser");
    if (registeredUser != null) {
        props = new GWikiProps(((GWikiPropsArtefakt) registeredUser.getMainPart()).getCompiledObject());
    }
    props.setStringValue(GWikiAuthorizationExt.USER_PROP_EMAIL, email);
    if (props.getStringValue(GWikiAuthorizationExt.USER_PROP_RIGHTSRULE, null) == null) {
        props.setStringValue(GWikiAuthorizationExt.USER_PROP_RIGHTSRULE, "GWIKI_VIEWPAGES");
    }
    props.setStringValue(GWikiAuthorizationExt.USER_PROP_PASSWORD, cp);
    Locale loc = wikiContext.getRequest().getLocale();
    GWikiGlobalConfig gc = wikiContext.getWikiWeb().getWikiConfig();

    if (loc != null) {
        String lang = loc.getLanguage();
        if (gc.getAvailableLanguages(wikiContext).contains(lang) == true) {
            props.setStringValue(GWikiAuthorizationExt.USER_LANG, lang);
        }
    }
    if (StringUtils.isEmpty(clientTzOffset) == false) {
        try {
            int offsetMin = Integer.parseInt(clientTzOffset);
            int daysaving = TimeZone.getDefault().getDSTSavings();
            int offsetMs = (offsetMin * 1000 * 60 * -1) - daysaving;
            int offsetHour = ((offsetMin / 60) * -1) - (daysaving / ((int) TimeInMillis.HOUR));
            String tzs = "Etc/GMT";
            if (offsetHour != 0) {
                if (offsetHour > 0) {
                    tzs += "+";
                }
                tzs += offsetHour;
            }
            List<String> tcs = gc.getAvailableTimeZones(wikiContext);
            if (tcs.contains(tzs) == true) {
                props.setStringValue(GWikiAuthorizationExt.USER_TZ, tzs);
            } else {
                // String[] offsets = TimeZone.getAvailableIDs(offsetMs);

                for (String tzss : tcs) {
                    TimeZone tz = TimeZone.getTimeZone(tzss);
                    int rawo = tz.getOffset(System.currentTimeMillis());
                    if (rawo == offsetMs) {
                        props.setStringValue(GWikiAuthorizationExt.USER_TZ, tzss);
                        break;
                    }
                }
            }
        } catch (NumberFormatException ex) {
            // ignore
        }
    }
    if (authExt.createUser(wikiContext, user, props) == false) {
        wikiContext.addValidationError("gwiki.page.admin.RegisterUser.message.internalerrorstore");
        return false;
    }
    if (doubleOptIn == true) {
        try {
            GWikiLoginActionBean.sendPasswordToUser(wikiContext, user, email, pass);

            wikiContext.addValidationError("gwiki.page.admin.Login.message.resetpassw.emailsent");
        } catch (Exception ex) {
            GWikiLog.error("Cannot send register email: " + ex.getMessage(), ex);
            wikiContext.addValidationError("gwiki.page.admin.RegisterUser.message.unabletosend");
        }
        showForm = false;
    } else {
        boolean success = wikiContext.getWikiWeb().getAuthorization().login(wikiContext, StringUtils.trim(user),
                StringUtils.trim(pass));
        if (success == false) {
            return false;
        }
    }
    return true;
}

From source file:fr.dutra.confluence2wordpress.wp.WordpressClient.java

/**
 * Date values are sent with no time zone information;
 * Wordpress assumes they are in UTC.//from w  w w. j a  va2  s  .co m
 * Hence the need to convert to a fake date bearing the correct information,
 * but in a wrong time zone.
 * @param date
 * @return
 */
private Date convertToNaiveUTC(Date date) {
    TimeZone zone = TimeZone.getDefault();
    long time = date.getTime();
    return new Date(time - zone.getOffset(time));
}

From source file:fr.dutra.confluence2wordpress.wp.WordpressClient.java

/**
 * Date values are received with no time zone information;
 * Wordpress assumes they are in UTC./*  w  ww. j  av a 2s .  c  o m*/
 * Hence the need to convert from a fake date bearing the correct information,
 * but in a wrong time zone.
 * @param date
 * @return
 */
private Date convertFromNaiveUTC(Date date) {
    TimeZone zone = TimeZone.getDefault();
    long time = date.getTime();
    return new Date(time + zone.getOffset(time));
}

From source file:com.appeligo.alerts.KeywordAlertChecker.java

/**
 * @param timeZone the user's timezone/*from   w  w w  . ja  va  2 s  . com*/
 * @param startOfDay We're using the value of earliestSmsTime (user account setting) as a starting point,
 * so anything before this time is credited to the previous day)
 * @return 12am (midnight) using system time (not user time) because "Date" objects stored in SQL
 * come back in system time.
 */
private Date calculateDay(TimeZone timeZone, Time startOfDay) {
    Calendar cal = Calendar.getInstance(timeZone);
    Calendar start = Calendar.getInstance();
    start.setTimeInMillis(startOfDay.getTime());
    cal.add(Calendar.HOUR_OF_DAY, 0 - start.get(Calendar.HOUR_OF_DAY));
    cal.add(Calendar.MINUTE, 0 - start.get(Calendar.MINUTE));
    cal.add(Calendar.SECOND, 0 - start.get(Calendar.SECOND));
    cal.clear(Calendar.MILLISECOND);
    cal.clear(Calendar.SECOND);
    cal.clear(Calendar.MINUTE);
    cal.clear(Calendar.HOUR_OF_DAY);
    cal.clear(Calendar.HOUR);
    cal.clear(Calendar.AM_PM);
    TimeZone systemTimeZone = TimeZone.getDefault();
    long now = System.currentTimeMillis();
    long difference = systemTimeZone.getOffset(now) - timeZone.getOffset(now);
    return new Date(cal.getTimeInMillis() - difference);
}

From source file:org.apache.jmeter.report.dashboard.HtmlTemplateExporter.java

@Override
public void export(SampleContext context, File file, ReportGeneratorConfiguration configuration)
        throws ExportException {
    Validate.notNull(context, MUST_NOT_BE_NULL, "context");
    Validate.notNull(file, MUST_NOT_BE_NULL, "file");
    Validate.notNull(configuration, MUST_NOT_BE_NULL, "configuration");

    LOG.debug("Start template processing");

    // Create data context and populate it
    DataContext dataContext = new DataContext();

    // Get the configuration of the current exporter
    final ExporterConfiguration exportCfg = configuration.getExportConfigurations().get(getName());

    // Get template directory property value
    File templateDirectory = getPropertyFromConfig(exportCfg, TEMPLATE_DIR,
            new File(JMeterUtils.getJMeterBinDir(), TEMPLATE_DIR_NAME_DEFAULT), File.class);
    if (!templateDirectory.isDirectory()) {
        String message = String.format(INVALID_TEMPLATE_DIRECTORY_FMT, templateDirectory.getAbsolutePath());
        LOG.error(message);/*from   w  ww  .ja v a2s  .c  om*/
        throw new ExportException(message);
    }

    // Get output directory property value
    File outputDir = getPropertyFromConfig(exportCfg, OUTPUT_DIR,
            new File(JMeterUtils.getJMeterBinDir(), OUTPUT_DIR_NAME_DEFAULT), File.class);
    String globallyDefinedOutputDir = JMeterUtils.getProperty(JMeter.JMETER_REPORT_OUTPUT_DIR_PROPERTY);
    if (!StringUtils.isEmpty(globallyDefinedOutputDir)) {
        outputDir = new File(globallyDefinedOutputDir);
    }

    JOrphanUtils.canSafelyWriteToFolder(outputDir);

    LOG.info("Will generate dashboard in folder:" + outputDir.getAbsolutePath());

    // Add the flag defining whether only sample series are filtered to the
    // context
    final boolean filtersOnlySampleSeries = exportCfg.filtersOnlySampleSeries();
    addToContext(DATA_CTX_FILTERS_ONLY_SAMPLE_SERIES, Boolean.valueOf(filtersOnlySampleSeries), dataContext);

    // Add the series filter to the context
    final String seriesFilter = exportCfg.getSeriesFilter();
    Pattern filterPattern = null;
    if (StringUtils.isNotBlank(seriesFilter)) {
        try {
            filterPattern = Pattern.compile(seriesFilter);
        } catch (PatternSyntaxException ex) {
            LOG.error(String.format("Invalid series filter: \"%s\", %s", seriesFilter, ex.getDescription()));
        }
    }
    addToContext(DATA_CTX_SERIES_FILTER, seriesFilter, dataContext);

    // Add the flag defining whether only controller series are displayed
    final boolean showControllerSeriesOnly = exportCfg.showControllerSeriesOnly();
    addToContext(DATA_CTX_SHOW_CONTROLLERS_ONLY, Boolean.valueOf(showControllerSeriesOnly), dataContext);

    JsonizerVisitor jsonizer = new JsonizerVisitor();
    Map<String, Object> storedData = context.getData();

    // Add begin date consumer result to the data context
    addResultToContext(ReportGenerator.BEGIN_DATE_CONSUMER_NAME, storedData, dataContext, jsonizer);

    // Add end date summary consumer result to the data context
    addResultToContext(ReportGenerator.END_DATE_CONSUMER_NAME, storedData, dataContext, jsonizer);

    // Add Apdex summary consumer result to the data context
    addResultToContext(ReportGenerator.APDEX_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);

    // Add errors summary consumer result to the data context
    addResultToContext(ReportGenerator.ERRORS_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);

    // Add requests summary consumer result to the data context
    addResultToContext(ReportGenerator.REQUESTS_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);

    // Add statistics summary consumer result to the data context
    addResultToContext(ReportGenerator.STATISTICS_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);

    // Collect graph results from sample context and transform them into
    // Json strings to inject in the data context
    ExtraOptionsResultCustomizer customizer = new ExtraOptionsResultCustomizer();
    EmptyGraphChecker checker = new EmptyGraphChecker(filtersOnlySampleSeries, showControllerSeriesOnly,
            filterPattern);
    for (Map.Entry<String, GraphConfiguration> graphEntry : configuration.getGraphConfigurations().entrySet()) {
        final String graphId = graphEntry.getKey();
        final GraphConfiguration graphConfiguration = graphEntry.getValue();
        final SubConfiguration extraOptions = exportCfg.getGraphExtraConfigurations().get(graphId);

        // Initialize customizer and checker
        customizer.setExtraOptions(extraOptions);
        checker.setExcludesControllers(graphConfiguration.excludesControllers());
        checker.setGraphId(graphId);

        // Export graph data
        addResultToContext(graphId, storedData, dataContext, jsonizer, customizer, checker);
    }

    // Replace the begin date with its formatted string and store the old
    // timestamp
    long oldTimestamp = formatTimestamp(ReportGenerator.BEGIN_DATE_CONSUMER_NAME, dataContext);

    // Replace the end date with its formatted string
    formatTimestamp(ReportGenerator.END_DATE_CONSUMER_NAME, dataContext);

    // Add time zone offset (that matches the begin date) to the context
    TimeZone timezone = TimeZone.getDefault();
    addToContext(DATA_CTX_TIMEZONE_OFFSET, Integer.valueOf(timezone.getOffset(oldTimestamp)), dataContext);

    // Add report title to the context
    if (!StringUtils.isEmpty(configuration.getReportTitle())) {
        dataContext.put(DATA_CTX_REPORT_TITLE, StringEscapeUtils.escapeHtml4(configuration.getReportTitle()));
    }

    // Add the test file name to the context
    addToContext(DATA_CTX_TESTFILE, file.getName(), dataContext);

    // Add the overall filter property to the context
    addToContext(DATA_CTX_OVERALL_FILTER, configuration.getSampleFilter(), dataContext);

    // Walk template directory to copy files and process templated ones
    Configuration templateCfg = new Configuration(Configuration.getVersion());
    try {
        templateCfg.setDirectoryForTemplateLoading(templateDirectory);
        templateCfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
        LOG.info("Report will be generated in:" + outputDir.getAbsolutePath() + ", creating folder structure");
        FileUtils.forceMkdir(outputDir);
        TemplateVisitor visitor = new TemplateVisitor(templateDirectory.toPath(), outputDir.toPath(),
                templateCfg, dataContext);
        Files.walkFileTree(templateDirectory.toPath(), visitor);
    } catch (IOException ex) {
        throw new ExportException("Unable to process template files.", ex);
    }

    LOG.debug("End of template processing");

}