Example usage for java.util Calendar HOUR

List of usage examples for java.util Calendar HOUR

Introduction

In this page you can find the example usage for java.util Calendar HOUR.

Prototype

int HOUR

To view the source code for java.util Calendar HOUR.

Click Source Link

Document

Field number for get and set indicating the hour of the morning or afternoon.

Usage

From source file:jobs.WarningMonitorJob.java

/**
 * Check alert table to see if there is an active Warning of the given Alert type and that they are not older then the stale hours limit. 
 * Active warnings are considered stale if they are older then the configured Stale hours options which defaults to 12.
 * @param aType/*from w  w  w .  j a v a 2s . c  o m*/
 * @return true if no active warnings or the active warning is over ignore limit time.
 */
public boolean isAlertTypeActive(AlertType aType, Options options) {
    List<Warning> resp = Warning.getActive(aType);
    if (resp.size() > 0) {
        //See if warning has gone stale.
        Warning mostRecent = resp.get(0);
        Calendar now = Calendar.getInstance();
        now.add(Calendar.HOUR, -1 * options.snoozeActiveWarnings_hours);
        Calendar lastDate = Calendar.getInstance();
        lastDate.setTime(mostRecent.dateTime);
        if (now.after(lastDate))
            return true;
    }
    return false;
}

From source file:com.concursive.connect.web.modules.calendar.utils.DimDimUtils.java

/**
 * Calls Dimdim server methods based on the action set on MeetingInviteesBean
 *
 * @param meetingInviteesBean - meeting parameters to be called are to be set to the class
 * @param attendeeUser        - host or participant based on the meeting action
 * @return - Url to dimdim server or the message returned
 *///  w  w  w  .j a v a  2 s  .co  m
public static HashMap<String, String> processDimdimMeeting(MeetingInviteesBean meetingInviteesBean,
        User attendeeUser) {
    //return result
    HashMap<String, String> resultMap = new HashMap<String, String>();

    try {
        //get meeting
        Meeting meeting = meetingInviteesBean.getMeeting();

        //get meeting host
        User hostUser = UserUtils.loadUser(meeting.getOwner());

        //comma separate the attendee mailids for dimdim
        String attendeeMailIds = "";
        if (meetingInviteesBean.getMembersFoundList() != null
                && meetingInviteesBean.getMembersFoundList().size() > 0) {
            Set<User> userSet = meetingInviteesBean.getMembersFoundList().keySet();
            for (User user : userSet) {
                attendeeMailIds += user.getEmail() + ", ";
            }
        }
        if (meetingInviteesBean.getMeetingChangeUsers() != null
                && meetingInviteesBean.getMeetingChangeUsers().size() > 0) {
            for (User user : meetingInviteesBean.getMeetingChangeUsers()) {
                attendeeMailIds += user.getEmail() + ", ";
            }
        }
        attendeeMailIds = trimComma(attendeeMailIds);

        //Modify meeting
        if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_EDIT
                || meetingInviteesBean.getAction() == ACTION_MEETING_APPROVE_JOIN) {
            //check for meetingId if not present then call schedule meeting
            if (!StringUtils.hasText(meeting.getDimdimMeetingId())) {
                meetingInviteesBean.setAction(ACTION_MEETING_DIMDIM_SCHEDULE);
                resultMap = processDimdimMeeting(meetingInviteesBean, attendeeUser);
                meetingInviteesBean.setAction(ACTION_MEETING_DIMDIM_EDIT);
                return resultMap;
            }

            //set the query string values as params
            Map<String, String> params = new HashMap<String, String>();
            params.put("name", meeting.getDimdimUsername());
            params.put("password", meeting.getDimdimPassword());
            params.put("meetingID", meeting.getDimdimMeetingId());

            SimpleDateFormat dtFormater = new SimpleDateFormat("MMMM dd, yyyy");

            TimeZone timeZone = Calendar.getInstance().getTimeZone();
            if (hostUser.getTimeZone() != null) {
                timeZone = TimeZone.getTimeZone(hostUser.getTimeZone());
            }
            Calendar calendar = Calendar.getInstance(timeZone);
            calendar.setTime(meeting.getStartDate());

            params.put("startDate", dtFormater.format(meeting.getStartDate()));
            params.put("endDate", dtFormater.format(meeting.getEndDate()));
            params.put("startHour", calendar.get(Calendar.HOUR) + "");
            params.put("startMinute", calendar.get(Calendar.MINUTE) + "");
            params.put("timeAMPM", calendar.get(Calendar.AM_PM) == 0 ? "AM" : "PM");
            params.put("confname", meeting.getTitle());
            params.put("timezone", timeZone.getID());
            params.put("feedback", hostUser.getEmail());
            if (StringUtils.hasText(attendeeMailIds)) {
                params.put("attendees", attendeeMailIds);
            }
            params.put("agenda", meeting.getDescription());
            if (meeting.getByInvitationOnly()) {
                params.put("attendeePwd", meeting.getDimdimMeetingKey());
                params.put("waitingarea", "false");
            } else {
                params.put("attendeePwd", "");
                params.put("waitingarea", "false");
            }
            params.put("response", "json");

            //post to dimdim server and process response
            LOG.debug("JSON POST");
            String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_EDIT;
            JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params));
            String resSuccess = dimdimResp.getString("code");
            String resText = dimdimResp.getJSONObject("data").getString("text");

            //get meetingid if successful
            if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) {
                resultMap.put(resSuccess, meeting.getDimdimMeetingId());
                return resultMap;
            }

            resultMap.put(resSuccess, resText);
            return resultMap;
        }

        //create a new meeting
        if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_SCHEDULE) {
            //set the query string values as params
            Map<String, String> params = new HashMap<String, String>();
            params.put("name", meeting.getDimdimUsername());
            params.put("password", meeting.getDimdimPassword());

            SimpleDateFormat dtFormater = new SimpleDateFormat("MMMM dd, yyyy");

            TimeZone timeZone = Calendar.getInstance().getTimeZone();
            if (hostUser.getTimeZone() != null) {
                timeZone = TimeZone.getTimeZone(hostUser.getTimeZone());
            }
            Calendar calendar = Calendar.getInstance(timeZone);
            calendar.setTime(meeting.getStartDate());

            params.put("startDate", dtFormater.format(meeting.getStartDate()));
            params.put("endDate", dtFormater.format(meeting.getEndDate()));
            params.put("startHour", calendar.get(Calendar.HOUR) + "");
            params.put("startMinute", calendar.get(Calendar.MINUTE) + "");
            params.put("timeAMPM", calendar.get(Calendar.AM_PM) == 0 ? "AM" : "PM");
            params.put("confname", meeting.getTitle());
            params.put("timezone", timeZone.getID());
            params.put("feedback", hostUser.getEmail());
            if (StringUtils.hasText(attendeeMailIds)) {
                params.put("attendees", attendeeMailIds);
            }
            params.put("agenda", meeting.getDescription());
            if (StringUtils.hasText(meeting.getDimdimMeetingKey())) {
                params.put("attendeePwd", meeting.getDimdimMeetingKey());
                params.put("waitingarea", "false");
            }
            params.put("response", "json");

            //post to dimdim server and process response
            LOG.debug("JSON POST");
            String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_SCHEDULE;
            JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params));
            String resSuccess = dimdimResp.getString("code");
            String resText = dimdimResp.getJSONObject("data").getString("text");

            //get meetingid if successful
            if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) {
                resText = resText.substring(resText.lastIndexOf("is ") + 3);
                resultMap.put(resSuccess, resText);
                return resultMap;
            }

            resultMap.put(resSuccess, resText);
            return resultMap;
        }

        //join an existing meeting
        if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_JOIN) {
            //set the query string values as params
            Map<String, String> params = new HashMap<String, String>();
            params.put("meetingRoomName", meeting.getDimdimUsername());
            params.put("displayname", attendeeUser.getNameFirstLast());
            if (StringUtils.hasText(meeting.getDimdimMeetingKey())) {
                params.put("attendeePwd", meeting.getDimdimMeetingKey());
            }
            params.put("response", "json");

            //post to dimdim server and process response
            LOG.debug("JSON POST");
            String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_JOIN;
            JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params));
            String resSuccess = dimdimResp.getString("code");
            String resText = dimdimResp.getJSONObject("data").getString("text");

            //if successful return dimdim url
            if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) {
                resultMap.put(resSuccess, urlPrefix + buildDimdimUrl(params));
                return resultMap;
            }

            resultMap.put(resSuccess, resText);
            return resultMap;
        }

        //start a meeting
        if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_START) {
            //set the query string values as params
            Map<String, String> params = new HashMap<String, String>();
            params.put("name", meeting.getDimdimUsername());
            params.put("password", meeting.getDimdimPassword());
            params.put("meetingID", meeting.getDimdimMeetingId());
            params.put("response", "json");

            //post to dimdim server and process response
            LOG.debug("JSON POST");
            String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_START;
            JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params));
            String resSuccess = dimdimResp.getString("code");
            String resText = dimdimResp.getJSONObject("data").getString("text");

            if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) {
                resultMap.put(resSuccess, urlPrefix + buildDimdimUrl(params));
                return resultMap;
            }

            resultMap.put(resSuccess, resText);
            return resultMap;
        }

        //delete a meeting
        if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_CANCEL) {
            //set the query string values as params
            Map<String, String> params = new HashMap<String, String>();
            params.put("name", meeting.getDimdimUsername());
            params.put("password", meeting.getDimdimPassword());
            params.put("meetingID", meeting.getDimdimMeetingId());
            params.put("response", "json");

            //post to dimdim server and process response
            LOG.debug("JSON POST");
            String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_DELETE;
            JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params));
            String resSuccess = dimdimResp.getString("code");
            String resText = dimdimResp.getJSONObject("data").getString("text");

            if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) {
                resultMap.put(resSuccess, urlPrefix + buildDimdimUrl(params));
                return resultMap;
            }

            resultMap.put(resSuccess, resText);
            return resultMap;
        }

        LOG.error("Unknown Dimdim meeting senario or action.");
        resultMap.put("0", "Error occured while accessing Dimdim server.");
        return resultMap;
    } catch (Exception e) {
        LOG.error(e.toString());
        resultMap.put("0", "Error occured while accessing Dimdim server.");
        return resultMap;
    }
}

From source file:org.activiti.rest.service.api.repository.ModelResourceTest.java

@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testUpdateModel() throws Exception {

    Model model = null;/* ww  w  . java  2s.  c  om*/
    try {
        Calendar createTime = Calendar.getInstance();
        createTime.set(Calendar.MILLISECOND, 0);
        processEngineConfiguration.getClock().setCurrentTime(createTime.getTime());

        model = repositoryService.newModel();
        model.setCategory("Model category");
        model.setKey("Model key");
        model.setMetaInfo("Model metainfo");
        model.setName("Model name");
        model.setVersion(2);
        repositoryService.saveModel(model);

        Calendar updateTime = Calendar.getInstance();
        updateTime.set(Calendar.MILLISECOND, 0);
        updateTime.add(Calendar.HOUR, 1);
        processEngineConfiguration.getClock().setCurrentTime(updateTime.getTime());

        // Create update request
        ObjectNode requestNode = objectMapper.createObjectNode();
        requestNode.put("name", "Updated name");
        requestNode.put("category", "Updated category");
        requestNode.put("key", "Updated key");
        requestNode.put("metaInfo", "Updated metainfo");
        requestNode.put("deploymentId", deploymentId);
        requestNode.put("version", 3);
        requestNode.put("tenantId", "myTenant");

        HttpPut httpPut = new HttpPut(
                SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId()));
        httpPut.setEntity(new StringEntity(requestNode.toString()));
        CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);

        JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
        closeResponse(response);
        assertNotNull(responseNode);
        assertEquals("Updated name", responseNode.get("name").textValue());
        assertEquals("Updated key", responseNode.get("key").textValue());
        assertEquals("Updated category", responseNode.get("category").textValue());
        assertEquals(3, responseNode.get("version").intValue());
        assertEquals("Updated metainfo", responseNode.get("metaInfo").textValue());
        assertEquals(deploymentId, responseNode.get("deploymentId").textValue());
        assertEquals(model.getId(), responseNode.get("id").textValue());
        assertEquals("myTenant", responseNode.get("tenantId").textValue());

        assertEquals(createTime.getTime().getTime(),
                getDateFromISOString(responseNode.get("createTime").textValue()).getTime());
        assertEquals(updateTime.getTime().getTime(),
                getDateFromISOString(responseNode.get("lastUpdateTime").textValue()).getTime());

        assertTrue(responseNode.get("url").textValue()
                .endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId())));
        assertTrue(responseNode.get("deploymentUrl").textValue()
                .endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, deploymentId)));

    } finally {
        try {
            repositoryService.deleteModel(model.getId());
        } catch (Throwable ignore) {
            // Ignore, model might not be created
        }
    }
}

From source file:org.flowable.rest.service.api.repository.ModelResourceTest.java

@Deployment(resources = { "org/flowable/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testUpdateModel() throws Exception {

    Model model = null;// w w  w.  j a va 2  s.  c  o  m
    try {
        Calendar createTime = Calendar.getInstance();
        createTime.set(Calendar.MILLISECOND, 0);
        processEngineConfiguration.getClock().setCurrentTime(createTime.getTime());

        model = repositoryService.newModel();
        model.setCategory("Model category");
        model.setKey("Model key");
        model.setMetaInfo("Model metainfo");
        model.setName("Model name");
        model.setVersion(2);
        repositoryService.saveModel(model);

        Calendar updateTime = Calendar.getInstance();
        updateTime.set(Calendar.MILLISECOND, 0);
        updateTime.add(Calendar.HOUR, 1);
        processEngineConfiguration.getClock().setCurrentTime(updateTime.getTime());

        // Create update request
        ObjectNode requestNode = objectMapper.createObjectNode();
        requestNode.put("name", "Updated name");
        requestNode.put("category", "Updated category");
        requestNode.put("key", "Updated key");
        requestNode.put("metaInfo", "Updated metainfo");
        requestNode.put("deploymentId", deploymentId);
        requestNode.put("version", 3);
        requestNode.put("tenantId", "myTenant");

        HttpPut httpPut = new HttpPut(
                SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId()));
        httpPut.setEntity(new StringEntity(requestNode.toString()));
        CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);

        JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
        closeResponse(response);
        assertNotNull(responseNode);
        assertEquals("Updated name", responseNode.get("name").textValue());
        assertEquals("Updated key", responseNode.get("key").textValue());
        assertEquals("Updated category", responseNode.get("category").textValue());
        assertEquals(3, responseNode.get("version").intValue());
        assertEquals("Updated metainfo", responseNode.get("metaInfo").textValue());
        assertEquals(deploymentId, responseNode.get("deploymentId").textValue());
        assertEquals(model.getId(), responseNode.get("id").textValue());
        assertEquals("myTenant", responseNode.get("tenantId").textValue());

        assertEquals(createTime.getTime().getTime(),
                getDateFromISOString(responseNode.get("createTime").textValue()).getTime());
        assertEquals(updateTime.getTime().getTime(),
                getDateFromISOString(responseNode.get("lastUpdateTime").textValue()).getTime());

        assertTrue(responseNode.get("url").textValue()
                .endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_MODEL, model.getId())));
        assertTrue(responseNode.get("deploymentUrl").textValue()
                .endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT, deploymentId)));

    } finally {
        try {
            repositoryService.deleteModel(model.getId());
        } catch (Throwable ignore) {
            // Ignore, model might not be created
        }
    }
}

From source file:com.unicornlabs.kabouter.gui.power.PowerPanel.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from   w w  w  .  j ava 2  s.  com*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jLabel1 = new javax.swing.JLabel();
    chartPanel = new ChartPanel(myChart);
    startDateChooser = new com.toedter.calendar.JDateChooser(new Date());
    jLabel2 = new javax.swing.JLabel();
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR, -6);
    startTimeSpinner = new com.unicornlabs.kabouter.gui.components.JTimeSpinner(cal.getTime());
    endDateChooser = new com.toedter.calendar.JDateChooser(new Date());
    endTimeSpinner = new com.unicornlabs.kabouter.gui.components.JTimeSpinner();
    jLabel3 = new javax.swing.JLabel();
    applyButton = new javax.swing.JButton();
    liveCheckBox = new javax.swing.JCheckBox();
    jScrollPane1 = new javax.swing.JScrollPane();
    deviceList = new javax.swing.JList();
    generateReportButton = new javax.swing.JButton();

    jLabel1.setText("Device IDs:");

    chartPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

    javax.swing.GroupLayout chartPanelLayout = new javax.swing.GroupLayout(chartPanel);
    chartPanel.setLayout(chartPanelLayout);
    chartPanelLayout.setHorizontalGroup(chartPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
    chartPanelLayout.setVerticalGroup(chartPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 423, Short.MAX_VALUE));

    jLabel2.setText("Graph Start Date:");

    jLabel3.setText("Graph End Date:");

    applyButton.setText("Apply");
    applyButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            applyButtonActionPerformed(evt);
        }
    });

    liveCheckBox.setText("Live");
    liveCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            liveCheckBoxActionPerformed(evt);
        }
    });

    deviceList.setModel(new javax.swing.AbstractListModel() {
        String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

        public int getSize() {
            return strings.length;
        }

        public Object getElementAt(int i) {
            return strings[i];
        }
    });
    jScrollPane1.setViewportView(deviceList);

    generateReportButton.setText("Generate Report");
    generateReportButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            generateReportButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chartPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup().addGroup(layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addGroup(layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(startTimeSpinner, javax.swing.GroupLayout.Alignment.LEADING,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(startDateChooser, javax.swing.GroupLayout.Alignment.LEADING,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE))
                            .addComponent(liveCheckBox)).addGap(73, 73, 73).addComponent(jLabel1)
                            .addGap(10, 10, 10)
                            .addComponent(
                                    jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE)
                            .addGap(69, 69, 69)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createSequentialGroup().addComponent(generateReportButton)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(applyButton))
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel3)
                                            .addGroup(layout
                                                    .createParallelGroup(
                                                            javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                    .addComponent(endTimeSpinner,
                                                            javax.swing.GroupLayout.Alignment.LEADING,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .addComponent(endDateChooser,
                                                            javax.swing.GroupLayout.Alignment.LEADING,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 145,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE))))))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addComponent(chartPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addGap(12, 12, 12).addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(startTimeSpinner, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(startDateChooser, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(liveCheckBox).addGap(39, 39, 39)
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(applyButton).addComponent(generateReportButton)))
                            .addGroup(layout.createSequentialGroup().addGap(18, 18, 18).addGroup(layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createSequentialGroup().addComponent(jLabel3)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(endTimeSpinner,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(endDateChooser,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addContainerGap()));
}

From source file:com.orange.cepheus.broker.LocalRegistrationsTest.java

@Test
public void test1MonthDuration() throws Exception {
    RegisterContext registerContext = createRegistrationContext();
    registerContext.setDuration("P1M");
    localRegistrations.updateRegistrationContext(registerContext);

    Calendar c = (Calendar) Calendar.getInstance().clone();
    c.add(Calendar.MONTH, 1);//from w w  w . j  av a  2s. co  m
    c.add(Calendar.HOUR, 24);
    Registration registration = localRegistrations.getRegistration(registerContext.getRegistrationId());
    assertFalse(registration.getExpirationDate().isAfter(c.toInstant()));
    c.add(Calendar.HOUR, -48);
    assertFalse(registration.getExpirationDate().isBefore(c.toInstant()));
}

From source file:org.flowable.rest.service.api.runtime.SignalsResourceTest.java

@Deployment(resources = {
        "org/flowable/rest/service/api/runtime/SignalsResourceTest.process-signal-start.bpmn20.xml" })
public void testQueryEventSubscriptions() throws Exception {
    Calendar hourAgo = Calendar.getInstance();
    hourAgo.add(Calendar.HOUR, -1);

    Calendar inAnHour = Calendar.getInstance();
    inAnHour.add(Calendar.HOUR, 1);

    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();

    EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();

    String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION);
    assertResultsPresentInDataResponse(url, eventSubscription.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION) + "?eventType=signal";
    assertResultsPresentInDataResponse(url, eventSubscription.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION) + "?eventName="
            + encode("The Signal");
    assertResultsPresentInDataResponse(url, eventSubscription.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION)
            + "?activityId=theStart";
    assertResultsPresentInDataResponse(url, eventSubscription.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION)
            + "?activityId=nonexisting";
    assertEmptyResultsPresentInDataResponse(url);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION)
            + "?processDefinitionId=" + processDefinition.getId();
    assertResultsPresentInDataResponse(url, eventSubscription.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION)
            + "?processDefinitionId=nonexisting";
    assertEmptyResultsPresentInDataResponse(url);

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION) + "?createdBefore="
            + getISODateString(inAnHour.getTime());
    assertResultsPresentInDataResponse(url, eventSubscription.getId());

    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_EVENT_SUBSCRIPTION_COLLECTION) + "?createdAfter="
            + getISODateString(hourAgo.getTime());
    assertResultsPresentInDataResponse(url, eventSubscription.getId());
}

From source file:com.peterphi.std.crypto.keygen.CaHelper.java

private static void setNotBeforeNotAfter(final X509V3CertificateGenerator gen, final int validForYears) {

    // Make sure the timezone is UTC (non-UTC timezones seem to cause PureTLS some problems, which causes globus problems)
    Calendar now = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
    now.setTimeZone(TimeZone.getTimeZone("UTC"));

    // Set Not Before to be 48 hours in the past
    now.add(Calendar.HOUR, -48);
    gen.setNotBefore(now.getTime());// ww w . j a  v  a2s . c  om

    // Set Not After to be 10 years after that
    now.add(Calendar.YEAR, validForYears);
    gen.setNotAfter(now.getTime());
}

From source file:mx.bigdata.sat.cfdi.TFDv11c33.java

private TimbreFiscalDigital createStamp(UUID uuid, Date date, String PAC, String leyenda)
        throws DatatypeConfigurationException {
    Calendar c = Calendar.getInstance();
    c.setTime(date);//from   ww w  . j a  va2s .c o  m
    ObjectFactory of = new ObjectFactory();
    TimbreFiscalDigital tfds = of.createTimbreFiscalDigital();
    tfds.setVersion("1.1");
    tfds.setUUID(uuid.toString());
    tfds.setFechaTimbrado(DatatypeFactory.newInstance().newXMLGregorianCalendar(c.get(Calendar.YEAR),
            c.get(Calendar.MONTH), c.get(Calendar.DATE), c.get(Calendar.HOUR), c.get(Calendar.MINUTE),
            c.get(Calendar.SECOND), DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED));
    tfds.setRfcProvCertif(PAC);
    tfds.setLeyenda(leyenda);
    tfds.setSelloCFD(document.getSello());
    BigInteger bi = cert.getSerialNumber();
    tfds.setNoCertificadoSAT(new String(bi.toByteArray()));
    return tfds;
}

From source file:com.stratelia.silverpeas.versioning.jcr.impl.AbstractJcrTestCase.java

@Before
public void onSetUp() throws Exception {
    System.getProperties().put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
    calend = Calendar.getInstance();
    calend.set(Calendar.MILLISECOND, 0);
    calend.set(Calendar.SECOND, 0);
    calend.set(Calendar.MINUTE, 15);
    calend.set(Calendar.HOUR, 9);
    calend.set(Calendar.DAY_OF_MONTH, 12);
    calend.set(Calendar.MONTH, Calendar.MARCH);
    calend.set(Calendar.YEAR, 2008);
    IDatabaseConnection connection = null;
    try {//from   w w  w  .  j a  v a 2  s  . c  o  m
        connection = new DatabaseConnection(datasource.getConnection());
        DatabaseOperation.CLEAN_INSERT.execute(connection, getDataSet());
    } catch (Exception ex) {
        throw ex;
    } finally {
        if (connection != null) {
            try {
                connection.getConnection().close();
            } catch (SQLException e) {
                throw e;
            }
        }
    }
}