Example usage for java.time ZonedDateTime getOffset

List of usage examples for java.time ZonedDateTime getOffset

Introduction

In this page you can find the example usage for java.time ZonedDateTime getOffset.

Prototype

@Override
public ZoneOffset getOffset() 

Source Link

Document

Gets the zone offset, such as '+01:00'.

Usage

From source file:org.cgiar.ccafs.marlo.action.summaries.ProjectHighlightsSummaryAction.java

@Override
public String execute() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {/*from   w w  w .ja  v a 2  s  .  c  om*/
        Resource reportResource;
        if (this.getSelectedFormat().equals(APConstants.SUMMARY_FORMAT_EXCEL)) {
            reportResource = resourceManager.createDirectly(
                    this.getClass().getResource("/pentaho/crp/ProjectHighlightsExcel.prpt"),
                    MasterReport.class);
        } else {
            reportResource = resourceManager.createDirectly(
                    this.getClass().getResource("/pentaho/crp/ProjectHighlightsPDF.prpt"), MasterReport.class);
        }

        MasterReport masterReport = (MasterReport) reportResource.getResource();
        String center = this.getLoggedCrp().getAcronym();
        // Get datetime
        ZonedDateTime timezone = ZonedDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm ");
        String zone = timezone.getOffset() + "";
        if (zone.equals("Z")) {
            zone = "+0";
        }
        String date = timezone.format(format) + "(GMT" + zone + ")";
        // Set Main_Query
        CompoundDataFactory cdf = CompoundDataFactory.normalize(masterReport.getDataFactory());
        String masterQueryName = "main";
        TableDataFactory sdf = (TableDataFactory) cdf.getDataFactoryForQuery(masterQueryName);
        TypedTableModel model = this.getMasterTableModel(center, date, String.valueOf(this.getSelectedYear()));
        sdf.addTable(masterQueryName, model);
        masterReport.setDataFactory(cdf);
        // Set i8n for pentaho
        masterReport = this.addi8nParameters(masterReport);
        // Get details band
        ItemBand masteritemBand = masterReport.getItemBand();
        // Create new empty subreport hash map
        HashMap<String, Element> hm = new HashMap<String, Element>();
        // method to get all the subreports in the prpt and store in the HashMap
        this.getAllSubreports(hm, masteritemBand);
        // Uncomment to see which Subreports are detecting the method getAllSubreports
        // System.out.println("Pentaho SubReports: " + hm);
        this.fillSubreport((SubReport) hm.get("project_highlight"), "project_highlight");
        if (this.getSelectedFormat().equals(APConstants.SUMMARY_FORMAT_EXCEL)) {
            ExcelReportUtil.createXLSX(masterReport, os);
            bytesXLSX = os.toByteArray();
        } else {
            PdfReportUtil.createPDF(masterReport, os);
            bytesPDF = os.toByteArray();
        }
        os.close();
    } catch (Exception e) {
        LOG.error("Error generating ProjectHighlights" + this.getSelectedFormat() + ": " + e.getMessage());
        throw e;
    }
    // Calculate time of generation
    long stopTime = System.currentTimeMillis();
    stopTime = stopTime - startTime;
    LOG.info("Downloaded successfully: " + this.getFileName() + ". User: "
            + this.getCurrentUser().getComposedCompleteName() + ". CRP: " + this.getLoggedCrp().getAcronym()
            + ". Time to generate: " + stopTime + "ms.");
    return SUCCESS;
}

From source file:org.cgiar.ccafs.marlo.action.summaries.ProjectHighlightSummaryAction.java

@Override
public String execute() throws Exception {
    if (projectHighlightID == null
            || projectHighLightManager.getProjectHighligthById(projectHighlightID) == null
            || projectHighLightManager.getProjectHighligthById(projectHighlightID)
                    .getProjectHighlightInfo(this.getSelectedPhase()) == null) {
        LOG.error("Project Highlight " + projectHighlightID + " Not found");
        return NOT_FOUND;
    } else {//  w w  w  . ja va  2 s  .c om
        projectHighlightInfo = projectHighLightManager.getProjectHighligthById(projectHighlightID)
                .getProjectHighlightInfo(this.getSelectedPhase());
    }
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        Resource reportResource = resourceManager.createDirectly(
                this.getClass().getResource("/pentaho/crp/ProjectHighlightPDF.prpt"), MasterReport.class);
        MasterReport masterReport = (MasterReport) reportResource.getResource();
        String center = this.getLoggedCrp().getAcronym();
        // Get datetime
        ZonedDateTime timezone = ZonedDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm ");
        String zone = timezone.getOffset() + "";
        if (zone.equals("Z")) {
            zone = "+0";
        }
        String date = timezone.format(format) + "(GMT" + zone + ")";
        // Set Main_Query
        CompoundDataFactory cdf = CompoundDataFactory.normalize(masterReport.getDataFactory());
        String masterQueryName = "main";
        TableDataFactory sdf = (TableDataFactory) cdf.getDataFactoryForQuery(masterQueryName);
        TypedTableModel model = this.getMasterTableModel(center, date, String.valueOf(this.getSelectedYear()));
        sdf.addTable(masterQueryName, model);
        masterReport.setDataFactory(cdf);
        // Set i8n for pentaho
        masterReport = this.addi8nParameters(masterReport);
        // Get details band
        ItemBand masteritemBand = masterReport.getItemBand();
        // Create new empty subreport hash map
        HashMap<String, Element> hm = new HashMap<String, Element>();
        // method to get all the subreports in the prpt and store in the HashMap
        this.getAllSubreports(hm, masteritemBand);
        // Uncomment to see which Subreports are detecting the method getAllSubreports
        // System.out.println("Pentaho SubReports: " + hm);
        this.fillSubreport((SubReport) hm.get("project_highlight"), "project_highlight");
        PdfReportUtil.createPDF(masterReport, os);
        bytesPDF = os.toByteArray();
        os.close();
    } catch (Exception e) {
        LOG.error("Error generating ProjectHighlights Summary: " + e.getMessage());
        throw e;
    }
    // Calculate time of generation
    long stopTime = System.currentTimeMillis();
    stopTime = stopTime - startTime;
    LOG.info("Downloaded successfully: " + this.getFileName() + ". User: " + this.getDownloadByUser()
            + ". CRP: " + this.getLoggedCrp().getAcronym() + ". Time to generate: " + stopTime + "ms.");
    return SUCCESS;
}

From source file:org.cgiar.ccafs.marlo.action.summaries.ProjectInnovationSummaryAction.java

@Override
public String execute() throws Exception {
    if (projectInnovationID == null
            || projectInnovationManager.getProjectInnovationById(projectInnovationID) == null
            || projectInnovationManager.getProjectInnovationById(projectInnovationID)
                    .getProjectInnovationInfo(this.getSelectedPhase()) == null) {
        LOG.error("Project Innovation " + projectInnovationID + " Not found");
        return NOT_FOUND;
    } else {/*from  ww  w .j  av  a 2 s  .  c o m*/
        projectInnovationInfo = projectInnovationManager.getProjectInnovationById(projectInnovationID)
                .getProjectInnovationInfo(this.getSelectedPhase());
    }
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        Resource reportResource = resourceManager.createDirectly(
                this.getClass().getResource("/pentaho/crp/ProjectInnovationPDF.prpt"), MasterReport.class);
        MasterReport masterReport = (MasterReport) reportResource.getResource();
        String center = this.getLoggedCrp().getAcronym();
        // Get datetime
        ZonedDateTime timezone = ZonedDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm ");
        String zone = timezone.getOffset() + "";
        if (zone.equals("Z")) {
            zone = "+0";
        }
        String date = timezone.format(format) + "(GMT" + zone + ")";
        // Set Main_Query
        CompoundDataFactory cdf = CompoundDataFactory.normalize(masterReport.getDataFactory());
        String masterQueryName = "main";
        TableDataFactory sdf = (TableDataFactory) cdf.getDataFactoryForQuery(masterQueryName);
        TypedTableModel model = this.getMasterTableModel(center, date, String.valueOf(this.getSelectedYear()));
        sdf.addTable(masterQueryName, model);
        masterReport.setDataFactory(cdf);
        // Set i8n for pentaho
        masterReport = this.addi8nParameters(masterReport);
        // Get details band
        ItemBand masteritemBand = masterReport.getItemBand();
        // Create new empty subreport hash map
        HashMap<String, Element> hm = new HashMap<String, Element>();
        // method to get all the subreports in the prpt and store in the HashMap
        this.getAllSubreports(hm, masteritemBand);
        // Uncomment to see which Subreports are detecting the method getAllSubreports
        // System.out.println("Pentaho SubReports: " + hm);
        this.fillSubreport((SubReport) hm.get("project_innovation"), "project_innovation");
        PdfReportUtil.createPDF(masterReport, os);
        bytesPDF = os.toByteArray();
        os.close();
    } catch (Exception e) {
        LOG.error("Error generating ProjectInnovation Summary: " + e.getMessage());
        throw e;
    }
    // Calculate time of generation
    long stopTime = System.currentTimeMillis();
    stopTime = stopTime - startTime;
    LOG.info("Downloaded successfully: " + this.getFileName() + ". User: " + this.getDownloadByUser()
            + ". CRP: " + this.getLoggedCrp().getAcronym() + ". Time to generate: " + stopTime + "ms.");
    return SUCCESS;
}

From source file:org.cgiar.ccafs.marlo.action.summaries.ReportingSummaryAction.java

private TypedTableModel getMasterTableModel(List<CrpProgram> flagships, List<CrpProgram> regions,
        ProjectPartner projectLeader) {//from w ww.j  ava  2  s. c  o m
    // Initialization of Model
    TypedTableModel model = new TypedTableModel(
            new String[] { "title", "center", "current_date", "project_submission", "cycle", "isNew",
                    "isAdministrative", "type", "isGlobal", "isPhaseOne", "budget_gender", "hasTargetUnit",
                    "hasW1W2Co", "hasActivities", "phaseID" },
            new Class[] { String.class, String.class, String.class, String.class, String.class, Boolean.class,
                    Boolean.class, String.class, Boolean.class, Boolean.class, Boolean.class, Boolean.class,
                    Boolean.class, Boolean.class, Long.class });
    // Filling title
    String title = "";
    if (projectLeader != null) {
        if (projectLeader.getInstitution() != null && projectLeader.getInstitution().getAcronym() != ""
                && projectLeader.getInstitution().getAcronym() != null) {
            title += projectLeader.getInstitution().getAcronym() + "-";
        }
    }
    if (projectInfo.getAdministrative() == false) {
        if (flagships != null) {
            if (!flagships.isEmpty()) {
                for (CrpProgram crpProgram : flagships) {
                    title += crpProgram.getAcronym() + "-";
                }
            }
        }
        if (projectInfo.getNoRegional() != null && projectInfo.getNoRegional()) {
            title += "Global" + "-";
        } else {
            if (regions != null && !regions.isEmpty()) {
                for (CrpProgram crpProgram : regions) {
                    title += crpProgram.getAcronym() + "-";
                }
            }
        }
    }
    title += "P" + Long.toString(projectID);
    // Get datetime
    ZonedDateTime timezone = ZonedDateTime.now();
    DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm ");
    String zone = timezone.getOffset() + "";
    if (zone.equals("Z")) {
        zone = "+0";
    }
    String currentDate = timezone.format(format) + "(GMT" + zone + ")";
    // Filling submission
    List<Submission> submissions = new ArrayList<>();
    for (Submission submission : project
            .getSubmissions().stream().filter(c -> c.getCycle().equals(this.getSelectedCycle())
                    && c.getYear() == this.getSelectedYear() && c.getUnSubmitUser() == null)
            .collect(Collectors.toList())) {
        submissions.add(submission);
    }
    String submission = "";
    if (!submissions.isEmpty()) {
        if (submissions.size() > 1) {
            LOG.error("More than one submission was found, the report will retrieve the first one");
        }
        Submission fisrtSubmission = submissions.get(0);
        String submissionDate = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm")
                .format(fisrtSubmission.getDateTime());
        submission = "Submitted on " + submissionDate + " (" + fisrtSubmission.getCycle() + " cycle "
                + fisrtSubmission.getYear() + ")";
    } else {
        if (!this.getSelectedCycle().isEmpty() && this.getSelectedYear() != 0) {
            if (this.getSelectedCycle().equals("Reporting")) {
                submission = "Submission for " + this.getSelectedCycle() + " cycle " + this.getSelectedYear()
                        + ": &lt;not submited&gt;";
            } else {
                submission = "Submission for " + this.getSelectedCycle() + " cycle " + this.getSelectedYear()
                        + ": &lt;pending&gt;";
            }
        } else {
            submission = "Submission for " + "&lt;Not Defined&gt;" + " cycle " + "&lt;Not Defined&gt;" + " year"
                    + ": &lt;Not Defined&gt;";
        }
    }

    // TODO: Get image from repository
    String centerURL = "";
    // set CRP imgage URL from repo
    // centerURL = this.getBaseUrl() + "/global/images/crps/" + project.getCrp().getAcronym() + ".png";
    // Add center url to LOG
    // LOG.info("Center URL is: " + centerURL);
    // Get The Crp/Center/Platform where the project was created
    GlobalUnitProject globalUnitProject = project.getGlobalUnitProjects().stream()
            .filter(gu -> gu.isActive() && gu.isOrigin()).collect(Collectors.toList()).get(0);
    centerURL = globalUnitProject.getGlobalUnit().getAcronym();
    Boolean isAdministrative = false;
    String type = "Research Project";
    if (projectInfo.getAdministrative() != null) {
        if (projectInfo.getAdministrative() == true) {
            type = "Management Project";
        }
        isAdministrative = projectInfo.getAdministrative();
    } else {
        isAdministrative = false;
    }
    Boolean isNew = this.isProjectNew(projectID);
    Boolean hasGender = false;
    try {
        hasGender = this.hasSpecificities(APConstants.CRP_BUDGET_GENDER);
    } catch (Exception e) {
        LOG.warn("Failed to get " + APConstants.CRP_BUDGET_GENDER
                + " parameter. Parameter will be set as false. Exception: " + e.getMessage());
        hasGender = false;
    }
    Boolean hasTargetUnit = false;
    if (targetUnitList.size() > 0) {
        hasTargetUnit = true;
    }

    Boolean hasActivities = false;
    try {
        hasActivities = this.hasSpecificities(APConstants.CRP_ACTIVITES_MODULE);
    } catch (Exception e) {
        LOG.warn("Failed to get " + APConstants.CRP_ACTIVITES_MODULE
                + " parameter. Parameter will be set as false. Exception: " + e.getMessage());
        hasActivities = false;
    }

    Long phaseID = this.getSelectedPhase().getId();

    model.addRow(new Object[] { title, centerURL, currentDate, submission, this.getSelectedCycle(), isNew,
            isAdministrative, type, projectInfo.getLocationGlobal(), this.isPhaseOne(), hasGender,
            hasTargetUnit, hasW1W2Co, hasActivities, phaseID });
    return model;
}

From source file:org.cgiar.ccafs.marlo.action.summaries.SearchTermsSummaryAction.java

@Override
public String execute() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {/*  ww  w. j  a  va  2 s.  co  m*/
        Resource reportResource = resourceManager.createDirectly(
                this.getClass().getResource("/pentaho/crp/SearchTerms.prpt"), MasterReport.class);
        MasterReport masterReport = (MasterReport) reportResource.getResource();
        String center = this.getLoggedCrp().getAcronym();
        // Get datetime
        ZonedDateTime timezone = ZonedDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm ");
        String zone = timezone.getOffset() + "";
        if (zone.equals("Z")) {
            zone = "+0";
        }
        String currentDate = timezone.format(format) + "(GMT" + zone + ")";
        String parameters = this.getRequest().getParameter("keys");
        if (parameters != null) {
            if (parameters.isEmpty()) {
                // Empty keys
            } else {
                // String parametersNotEspecialChar = parameters.replaceAll("[^a-zA-Z0-9]+", "");
                keys = Arrays.asList(parameters.split(","));
            }
        }
        // Set Main_Query
        CompoundDataFactory cdf = CompoundDataFactory.normalize(masterReport.getDataFactory());
        String masterQueryName = "main";
        TableDataFactory sdf = (TableDataFactory) cdf.getDataFactoryForQuery(masterQueryName);
        TypedTableModel model = this.getMasterTableModel(center, currentDate);
        sdf.addTable(masterQueryName, model);
        masterReport.setDataFactory(cdf);
        // Set i8n for pentaho
        masterReport = this.addi8nParameters(masterReport);
        // Get details band
        ItemBand masteritemBand = masterReport.getItemBand();
        // Create new empty subreport hash map
        HashMap<String, Element> hm = new HashMap<String, Element>();
        // method to get all the subreports in the prpt and store in the HashMap
        this.getAllSubreports(hm, masteritemBand);
        // Uncomment to see which Subreports are detecting the method getAllSubreports
        // System.out.println("Pentaho SubReports: " + hm);
        this.fillSubreport((SubReport) hm.get("projects_details"), "project");
        this.fillSubreport((SubReport) hm.get("projects_activities"), "activities");
        this.fillSubreport((SubReport) hm.get("projects_deliverables"), "deliverables");
        ExcelReportUtil.createXLSX(masterReport, os);
        bytesXLSX = os.toByteArray();
        os.close();
    } catch (Exception e) {
        LOG.error("Error generating PDF " + e.getMessage());
        throw e;
    }
    // Calculate time of generation
    long stopTime = System.currentTimeMillis();
    stopTime = stopTime - startTime;
    LOG.info("Downloaded successfully: " + this.getFileName() + ". User: "
            + this.getCurrentUser().getComposedCompleteName() + ". CRP: " + this.getLoggedCrp().getAcronym()
            + ". Cycle: " + this.getSelectedCycle() + ". Time to generate: " + stopTime + "ms.");
    return SUCCESS;
}

From source file:org.cgiar.ccafs.marlo.action.summaries.StudiesSummaryAction.java

@Override
public String execute() throws Exception {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {//from w ww . ja  va2  s . com
        Resource reportResource;
        if (this.getSelectedFormat().equals(APConstants.SUMMARY_FORMAT_EXCEL)) {
            reportResource = resourceManager.createDirectly(
                    this.getClass().getResource("/pentaho/crp/CaseStudiesExcel.prpt"), MasterReport.class);
        } else {
            reportResource = resourceManager.createDirectly(
                    this.getClass().getResource("/pentaho/crp/StudiesPDF.prpt"), MasterReport.class);
        }
        MasterReport masterReport = (MasterReport) reportResource.getResource();
        String center = this.getLoggedCrp().getAcronym();

        // Get datetime
        ZonedDateTime timezone = ZonedDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm ");
        String zone = timezone.getOffset() + "";
        if (zone.equals("Z")) {
            zone = "+0";
        }
        String date = timezone.format(format) + "(GMT" + zone + ")";

        // Set Main_Query
        CompoundDataFactory cdf = CompoundDataFactory.normalize(masterReport.getDataFactory());
        String masterQueryName = "main";
        TableDataFactory sdf = (TableDataFactory) cdf.getDataFactoryForQuery(masterQueryName);
        TypedTableModel model = this.getMasterTableModel(center, date, String.valueOf(this.getSelectedYear()));
        sdf.addTable(masterQueryName, model);
        masterReport.setDataFactory(cdf);
        // Set i8n for pentaho
        masterReport = this.addi8nParameters(masterReport);
        // Get details band
        ItemBand masteritemBand = masterReport.getItemBand();
        // Create new empty subreport hash map
        HashMap<String, Element> hm = new HashMap<String, Element>();
        // method to get all the subreports in the prpt and store in the HashMap
        this.getAllSubreports(hm, masteritemBand);
        // Uncomment to see which Subreports are detecting the method getAllSubreports
        // System.out.println("Pentaho SubReports: " + hm);

        this.fillSubreport((SubReport) hm.get("case_studies"), "case_studies");

        if (this.getSelectedFormat().equals(APConstants.SUMMARY_FORMAT_EXCEL)) {
            ExcelReportUtil.createXLSX(masterReport, os);
            bytesXLSX = os.toByteArray();
        } else {
            PdfReportUtil.createPDF(masterReport, os);
            bytesPDF = os.toByteArray();
        }
        os.close();
    } catch (Exception e) {
        LOG.error("Error generating CaseStudy" + this.getSelectedFormat() + ": " + e.getMessage());
        throw e;
    }
    // Calculate time of generation
    long stopTime = System.currentTimeMillis();
    stopTime = stopTime - startTime;
    LOG.info("Downloaded successfully: " + this.getFileName() + ". User: "
            + this.getCurrentUser().getComposedCompleteName() + ". CRP: " + this.getLoggedCrp().getAcronym()
            + ". Time to generate: " + stopTime + "ms.");
    return SUCCESS;
}

From source file:org.cgiar.ccafs.marlo.action.summaries.StudySummaryAction.java

@Override
public String execute() throws Exception {
    if (projectExpectedStudyID == null
            || projectExpectedStudyManager.getProjectExpectedStudyById(projectExpectedStudyID) == null
            || projectExpectedStudyManager.getProjectExpectedStudyById(projectExpectedStudyID)
                    .getProjectExpectedStudyInfo(this.getSelectedPhase()) == null) {
        LOG.error("ProjectExpectedStudy " + projectExpectedStudyID + " Not found");
        return NOT_FOUND;
    } else {//from w  ww .  j a  v a  2  s.  c  o m
        projectExpectedStudyInfo = projectExpectedStudyManager
                .getProjectExpectedStudyById(projectExpectedStudyID)
                .getProjectExpectedStudyInfo(this.getSelectedPhase());
    }
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        Resource reportResource = resourceManager
                .createDirectly(this.getClass().getResource("/pentaho/crp/StudyPDF.prpt"), MasterReport.class);
        MasterReport masterReport = (MasterReport) reportResource.getResource();
        String center = this.getLoggedCrp().getAcronym();

        // Get datetime
        ZonedDateTime timezone = ZonedDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm ");
        String zone = timezone.getOffset() + "";
        if (zone.equals("Z")) {
            zone = "+0";
        }
        String date = timezone.format(format) + "(GMT" + zone + ")";

        // Set Main_Query
        CompoundDataFactory cdf = CompoundDataFactory.normalize(masterReport.getDataFactory());
        String masterQueryName = "main";
        TableDataFactory sdf = (TableDataFactory) cdf.getDataFactoryForQuery(masterQueryName);
        TypedTableModel model = this.getMasterTableModel(center, date, String.valueOf(this.getSelectedYear()));
        sdf.addTable(masterQueryName, model);
        masterReport.setDataFactory(cdf);
        // Set i8n for pentaho
        masterReport = this.addi8nParameters(masterReport);
        // Get details band
        ItemBand masteritemBand = masterReport.getItemBand();
        // Create new empty subreport hash map
        HashMap<String, Element> hm = new HashMap<String, Element>();
        // method to get all the subreports in the prpt and store in the HashMap
        this.getAllSubreports(hm, masteritemBand);
        // Uncomment to see which Subreports are detecting the method getAllSubreports
        // System.out.println("Pentaho SubReports: " + hm);

        this.fillSubreport((SubReport) hm.get("study"), "study");

        PdfReportUtil.createPDF(masterReport, os);
        bytesPDF = os.toByteArray();
        os.close();
    } catch (Exception e) {
        LOG.error("Error generating Study Summary: " + e.getMessage());
        throw e;
    }
    // Calculate time of generation
    long stopTime = System.currentTimeMillis();
    stopTime = stopTime - startTime;
    LOG.info("Downloaded successfully: " + this.getFileName() + ". User: " + this.getDownloadByUser()
            + ". CRP: " + this.getLoggedCrp().getAcronym() + ". Time to generate: " + stopTime + "ms.");
    return SUCCESS;
}

From source file:org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest.java

protected static String getTestTimeZone() {
    final ZonedDateTime currentTime = ZonedDateTime.now();
    return currentTime.getOffset().getId().replace("Z", "+00:00");
}

From source file:org.openhab.binding.ntp.test.NtpOSGiTest.java

@Test
public void testDateTimeChannelTimeZoneUpdate() {

    Configuration configuration = new Configuration();
    configuration.put(NtpBindingConstants.PROPERTY_TIMEZONE, TEST_TIME_ZONE_ID);
    initialize(configuration, NtpBindingConstants.CHANNEL_DATE_TIME, ACCEPTED_ITEM_TYPE_DATE_TIME, null, null);

    String testItemState = getItemState(ACCEPTED_ITEM_TYPE_DATE_TIME).toString();
    assertFormat(testItemState, DateTimeType.DATE_PATTERN_WITH_TZ_AND_MS);
    ZonedDateTime timeZoneFromItemRegistry = ((DateTimeType) getItemState(ACCEPTED_ITEM_TYPE_DATE_TIME))
            .getZonedDateTime();//from   w w  w .  j  av  a 2s  . c o  m

    ZoneOffset expectedOffset = ZoneId.of(TEST_TIME_ZONE_ID).getRules()
            .getOffset(timeZoneFromItemRegistry.toInstant());
    assertEquals(expectedOffset, timeZoneFromItemRegistry.getOffset());
}

From source file:org.openhab.binding.ntp.test.NtpOSGiTest.java

@Test
public void testDateTimeChannelCalendarTimeZoneUpdate() {
    Configuration configuration = new Configuration();
    configuration.put(NtpBindingConstants.PROPERTY_TIMEZONE, TEST_TIME_ZONE_ID);
    initialize(configuration, NtpBindingConstants.CHANNEL_DATE_TIME, ACCEPTED_ITEM_TYPE_DATE_TIME, null, null);
    ZonedDateTime timeZoneIdFromItemRegistry = ((DateTimeType) getItemState(ACCEPTED_ITEM_TYPE_DATE_TIME))
            .getZonedDateTime();//from  ww w . j  a  va2 s  .co  m

    ZoneOffset expectedOffset = ZoneId.of(TEST_TIME_ZONE_ID).getRules()
            .getOffset(timeZoneIdFromItemRegistry.toInstant());
    assertEquals(expectedOffset, timeZoneIdFromItemRegistry.getOffset());
}