Example usage for javax.xml.datatype XMLGregorianCalendar setMinute

List of usage examples for javax.xml.datatype XMLGregorianCalendar setMinute

Introduction

In this page you can find the example usage for javax.xml.datatype XMLGregorianCalendar setMinute.

Prototype

public abstract void setMinute(int minute);

Source Link

Document

Set minutes.

Usage

From source file:DatatypeAPIUsage.java

public static void main(String[] args) {
    try {//w ww  .  j  a v  a2s .  co  m
        DatatypeFactory df = DatatypeFactory.newInstance();
        // my work number in milliseconds:
        Duration myPhone = df.newDuration(9054133519l);
        Duration myLife = df.newDuration(true, 29, 2, 15, 13, 45, 0);
        int compareVal = myPhone.compare(myLife);
        switch (compareVal) {
        case DatatypeConstants.LESSER:
            System.out.println("There are fewer milliseconds in my phone number than my lifespan.");
            break;
        case DatatypeConstants.EQUAL:
            System.out.println("The same number of milliseconds are in my phone number and my lifespan.");
            break;
        case DatatypeConstants.GREATER:
            System.out.println("There are more milliseconds in my phone number than my lifespan.");
            break;
        case DatatypeConstants.INDETERMINATE:
            System.out.println("The comparison could not be carried out.");
        }

        // create a yearMonthDuration
        Duration ymDuration = df.newDurationYearMonth("P12Y10M");
        System.out.println("P12Y10M is of type: " + ymDuration.getXMLSchemaType());

        // create a dayTimeDuration (really this time)
        Duration dtDuration = df.newDurationDayTime("P10DT10H12M0S");
        System.out.println("P10DT10H12M0S is of type: " + dtDuration.getXMLSchemaType());

        // try to fool the factory!
        try {
            ymDuration = df.newDurationYearMonth("P12Y10M1D");
        } catch (IllegalArgumentException e) {
            System.out.println("'duration': P12Y10M1D is not 'yearMonthDuration'!!!");
        }

        XMLGregorianCalendar xgc = df.newXMLGregorianCalendar();
        xgc.setYear(1975);
        xgc.setMonth(DatatypeConstants.AUGUST);
        xgc.setDay(11);
        xgc.setHour(6);
        xgc.setMinute(44);
        xgc.setSecond(0);
        xgc.setMillisecond(0);
        xgc.setTimezone(5);
        xgc.add(myPhone);
        System.out.println("The approximate end of the number of milliseconds in my phone number was " + xgc);

        // adding a duration to XMLGregorianCalendar
        xgc.add(myLife);
        System.out.println("Adding the duration myLife to the above calendar:" + xgc);

        // create a new XMLGregorianCalendar using the string format of xgc.
        XMLGregorianCalendar xgcCopy = df.newXMLGregorianCalendar(xgc.toXMLFormat());

        // should be equal-if not what happened!!
        if (xgcCopy.compare(xgc) != DatatypeConstants.EQUAL) {
            System.out.println("oooops!");
        } else {
            System.out.println("Very good: " + xgc + " is equal to " + xgcCopy);
        }
    } catch (DatatypeConfigurationException dce) {
        System.err.println("error: Datatype error occurred - " + dce.getMessage());
        dce.printStackTrace(System.err);
    }
}

From source file:edu.harvard.i2b2.query.data.QueryConceptTreePanelData.java

public ConstrainByDate writeTimeConstraint() {
    ConstrainByDate timeConstrain = new ConstrainByDate();
    DTOFactory dtoFactory = new DTOFactory();

    TimeZone tz = Calendar.getInstance().getTimeZone();
    GregorianCalendar cal = new GregorianCalendar(tz);
    //cal.get(Calendar.ZONE_OFFSET);
    int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
    log.info("Timezone: " + tz.getID() + " : " + zt_offset);

    if (startTime() != -1) {
        ConstrainDateType constraindateType = new ConstrainDateType();
        XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(startYear(), startMonth() + 1,
                startDay());/*w ww.  j  a v  a 2s  .  co  m*/
        xmlC.setTimezone(zt_offset);//0);//-5*60);
        xmlC.setHour(0);
        xmlC.setMinute(0);
        xmlC.setSecond(0);
        constraindateType.setValue(xmlC);
        timeConstrain.setDateFrom(constraindateType);
    }

    if (endTime() != -1) {
        ConstrainDateType constraindateType = new ConstrainDateType();
        XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(endYear(), endMonth() + 1, endDay());
        xmlC.setTimezone(zt_offset);//0);//-5*60);
        xmlC.setHour(0);
        xmlC.setMinute(0);
        xmlC.setSecond(0);
        constraindateType.setValue(xmlC);
        timeConstrain.setDateTo(constraindateType);
    }
    return timeConstrain;
}

From source file:net.servicefixture.converter.XMLGregorianCalendarConverter.java

private XMLGregorianCalendar calendarToXMLGregorianCalendar(Calendar calendar) {
    XMLGregorianCalendar xmlCal;
    try {//from ww  w.j  av a  2 s  . c  o  m
        xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar();
    } catch (DatatypeConfigurationException e) {
        throw new RuntimeException("Failed to create XMLGregorianCalendar", e);
    }

    xmlCal.setYear(calendar.get(Calendar.YEAR));
    xmlCal.setMonth(calendar.get(Calendar.MONTH) + 1);
    xmlCal.setDay(calendar.get(Calendar.DAY_OF_MONTH));
    xmlCal.setHour(calendar.get(Calendar.HOUR));
    xmlCal.setMinute(calendar.get(Calendar.MINUTE));
    xmlCal.setSecond(calendar.get(Calendar.SECOND));
    xmlCal.setMillisecond(calendar.get(Calendar.MILLISECOND));
    return xmlCal;
}

From source file:com.evolveum.midpoint.certification.impl.AccCertUpdateHelper.java

protected AccessCertificationStageType createStage(AccessCertificationCampaignType campaign,
        int requestedStageNumber) {
    AccessCertificationStageType stage = new AccessCertificationStageType(prismContext);
    stage.setNumber(requestedStageNumber);
    stage.setStart(XmlTypeConverter.createXMLGregorianCalendar(new Date()));

    AccessCertificationStageDefinitionType stageDef = CertCampaignTypeUtil.findStageDefinition(campaign,
            stage.getNumber());//from ww w.  j av a 2s .c  o m
    XMLGregorianCalendar end = (XMLGregorianCalendar) stage.getStart().clone();
    if (stageDef.getDays() != null) {
        end.add(XmlTypeConverter.createDuration(true, 0, 0, stageDef.getDays(), 0, 0, 0));
    }
    end.setHour(23);
    end.setMinute(59);
    end.setSecond(59);
    end.setMillisecond(999);
    stage.setEnd(end);

    stage.setName(stageDef.getName());
    stage.setDescription(stageDef.getDescription());

    return stage;
}

From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java

private void jForwardButtonActionPerformed(java.awt.event.ActionEvent evt) {
    System.out.println("Loading previous queries for: " + System.getProperty("user"));

    cellStatus = "";
    String searchStr = jSearchStringTextField.getText();
    int category = jCategoryComboBox.getSelectedIndex();
    int strategy = jContainComboBox.getSelectedIndex();

    curCreationDate = previousQueries.get(previousQueries.size() - 1).creationTime();
    ////////////////////////////////////////////////
    SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance();
    Date date = null;/*from ww w . j a  va  2s.  c  om*/
    try {
        date = df.parse(this.jStartTimeTextField.getText());
    } catch (Exception e) {
        e.printStackTrace();
    }
    DTOFactory dtoFactory = new DTOFactory();

    TimeZone tz = Calendar.getInstance().getTimeZone();
    GregorianCalendar cal = new GregorianCalendar(tz);
    cal.setTime(date);
    //cal.get(Calendar.ZONE_OFFSET);
    int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
    //log.info("Timezone: "+tz.getID()+" : "+zt_offset);

    //if (startTime() != -1) {
    ConstrainDateType constraindateType = new ConstrainDateType();
    XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR),
            cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH));
    xmlC.setTimezone(zt_offset);//0);//-5*60);
    xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY));
    xmlC.setMinute(cal.get(GregorianCalendar.MINUTE));
    xmlC.setSecond(cal.get(GregorianCalendar.SECOND));
    constraindateType.setValue(xmlC);
    //timeConstrain.setDateFrom(constraindateType);
    //}
    ////////////////////////////////////////////////
    String xmlStr = writePagingQueryXML("", category, strategy, false, xmlC);//curCreationDate);
    // System.out.println(xmlStr);

    String responseStr = null;
    if (System.getProperty("webServiceMethod").equals("SOAP")) {
        responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr);
    } else {
        responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr);
    }

    if (responseStr.equalsIgnoreCase("CellDown")) {
        cellStatus = new String("CellDown");
        return; //"CellDown";
    }

    try {
        JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();
        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr);
        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
        BodyType bt = messageType.getMessageBody();
        MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass(
                bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class);
        for (Condition status : masterResponseType.getStatus().getCondition()) {
            if (status.getType().equals("ERROR"))
                cellStatus = new String("CellDown");
        }
        previousQueries = new ArrayList<QueryMasterData>();
        for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) {
            QueryMasterData tmpData;
            tmpData = new QueryMasterData();
            XMLGregorianCalendar cldr = queryMasterType.getCreateDate();
            tmpData.name(
                    queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay())
                            + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]");
            tmpData.creationTime(cldr);//.clone());
            tmpData.creationTimeStr(
                    addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear())
                            + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond());
            tmpData.tooltip("A query run by " + queryMasterType.getUserId());// System.
            // getProperty
            // ("user"));
            tmpData.visualAttribute("CA");
            tmpData.xmlContent(null);
            tmpData.id(queryMasterType.getQueryMasterId());
            tmpData.userId(queryMasterType.getUserId()); // System.getProperty
            // ("user"));
            previousQueries.add(tmpData);
        }

        if (previousQueries.size() == 0) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            });
            return;
        }

        if (cellStatus.equalsIgnoreCase("")) {
            reset(200, false, false);
        } else if (cellStatus.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
        return;
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
}

From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java

private void jBackwardButtonActionPerformed(java.awt.event.ActionEvent evt) {
    /*LoginHelper pms = new LoginHelper();
    try {//from ww  w .  j  a v a2  s. com
       PasswordType ptype = new PasswordType();
       ptype.setIsToken(UserInfoBean.getInstance().getUserPasswordIsToken());
       ptype.setTokenMsTimeout(UserInfoBean.getInstance()
       .getUserPasswordTimeout());
       ptype.setValue(UserInfoBean.getInstance().getUserPassword());
       String response = pms.getUserInfo(UserInfoBean.getInstance().getUserName(), ptype, UserInfoBean.getInstance().getSelectedProjectUrl(), 
       UserInfoBean.getInstance().getUserDomain(), false, UserInfoBean.getInstance().getProjectId());
    }
    catch(Exception e) {
       e.printStackTrace();
    }*/

    System.out.println("Loading previous queries for: " + System.getProperty("user"));

    cellStatus = "";
    String searchStr = jSearchStringTextField.getText();
    int category = jCategoryComboBox.getSelectedIndex();
    int strategy = jContainComboBox.getSelectedIndex();

    curCreationDate = previousQueries.get(0).creationTime();
    ////////////////////////////////////////////////
    SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance();
    Date date = null;
    try {
        date = df.parse(this.jStartTimeTextField.getText());
    } catch (Exception e) {
        e.printStackTrace();
    }
    DTOFactory dtoFactory = new DTOFactory();

    TimeZone tz = Calendar.getInstance().getTimeZone();
    GregorianCalendar cal = new GregorianCalendar(tz);
    cal.setTime(date);
    //cal.get(Calendar.ZONE_OFFSET);
    int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
    //log.info("Timezone: "+tz.getID()+" : "+zt_offset);

    //if (startTime() != -1) {
    ConstrainDateType constraindateType = new ConstrainDateType();
    XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR),
            cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH));
    xmlC.setTimezone(zt_offset);//0);//-5*60);
    xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY));
    xmlC.setMinute(cal.get(GregorianCalendar.MINUTE));
    xmlC.setSecond(cal.get(GregorianCalendar.SECOND));
    constraindateType.setValue(xmlC);
    //timeConstrain.setDateFrom(constraindateType);
    //}
    ////////////////////////////////////////////////
    String xmlStr = writePagingQueryXML("", category, strategy, true, xmlC);//curCreationDate);
    // System.out.println(xmlStr);

    String responseStr = null;
    if (System.getProperty("webServiceMethod").equals("SOAP")) {
        responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr);
    } else {
        responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr);
    }

    if (responseStr.equalsIgnoreCase("CellDown")) {
        cellStatus = new String("CellDown");
        return; //"CellDown";
    }

    try {
        JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();
        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr);
        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
        BodyType bt = messageType.getMessageBody();
        MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass(
                bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class);
        for (Condition status : masterResponseType.getStatus().getCondition()) {
            if (status.getType().equals("ERROR"))
                cellStatus = new String("CellDown");
        }
        previousQueries = new ArrayList<QueryMasterData>();
        for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) {
            QueryMasterData tmpData;
            tmpData = new QueryMasterData();
            XMLGregorianCalendar cldr = queryMasterType.getCreateDate();
            tmpData.name(
                    queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay())
                            + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]");
            tmpData.creationTime(cldr);//.clone());
            tmpData.creationTimeStr(
                    addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear())
                            + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond());
            tmpData.tooltip("A query run by " + queryMasterType.getUserId());// System.
            // getProperty
            // ("user"));
            tmpData.visualAttribute("CA");
            tmpData.xmlContent(null);
            tmpData.id(queryMasterType.getQueryMasterId());
            tmpData.userId(queryMasterType.getUserId()); // System.getProperty
            // ("user"));
            previousQueries.add(tmpData);
        }

        if (previousQueries.size() == 0) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            });
            return;
        }

        if (cellStatus.equalsIgnoreCase("")) {
            reset(200, false, true);
        } else if (cellStatus.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
        return;
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
}

From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java

@SuppressWarnings("rawtypes")
private void jForwardButtonActionPerformed(java.awt.event.ActionEvent evt) {
    System.out.println("Loading previous queries for: " + System.getProperty("user"));

    cellStatus = "";
    //String searchStr = jSearchStringTextField.getText();
    int category = jCategoryComboBox.getSelectedIndex();
    int strategy = jContainComboBox.getSelectedIndex();

    curCreationDate = previousQueries.get(previousQueries.size() - 1).creationTime();
    ////////////////////////////////////////////////
    SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance();
    Date date = null;//w  ww .jav a2 s  .com
    try {
        date = df.parse(this.jStartTimeTextField.getText());
    } catch (Exception e) {
        e.printStackTrace();
    }
    DTOFactory dtoFactory = new DTOFactory();

    TimeZone tz = Calendar.getInstance().getTimeZone();
    GregorianCalendar cal = new GregorianCalendar(tz);
    cal.setTime(date);
    //cal.get(Calendar.ZONE_OFFSET);
    int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
    //log.info("Timezone: "+tz.getID()+" : "+zt_offset);

    //if (startTime() != -1) {
    ConstrainDateType constraindateType = new ConstrainDateType();
    XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR),
            cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH));
    xmlC.setTimezone(zt_offset);//0);//-5*60);
    xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY));
    xmlC.setMinute(cal.get(GregorianCalendar.MINUTE));
    xmlC.setSecond(cal.get(GregorianCalendar.SECOND));
    constraindateType.setValue(xmlC);
    //timeConstrain.setDateFrom(constraindateType);
    //}
    ////////////////////////////////////////////////
    String xmlStr = writePagingQueryXML("", category, strategy, false, xmlC);//curCreationDate);
    // System.out.println(xmlStr);

    String responseStr = null;
    if (System.getProperty("webServiceMethod").equals("SOAP")) {
        responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr);
    } else {
        responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr);
    }

    if (responseStr.equalsIgnoreCase("CellDown")) {
        cellStatus = new String("CellDown");
        return; //"CellDown";
    }

    try {
        JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil();
        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr);
        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
        BodyType bt = messageType.getMessageBody();
        MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass(
                bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class);
        for (Condition status : masterResponseType.getStatus().getCondition()) {
            if (status.getType().equals("ERROR"))
                cellStatus = new String("CellDown");
        }
        previousQueries = new ArrayList<QueryMasterData>();
        for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) {
            QueryMasterData tmpData;
            tmpData = new QueryMasterData();
            XMLGregorianCalendar cldr = queryMasterType.getCreateDate();
            tmpData.name(
                    queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay())
                            + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]");
            tmpData.creationTime(cldr);//.clone());
            tmpData.creationTimeStr(
                    addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear())
                            + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond());
            tmpData.tooltip("A query run by " + queryMasterType.getUserId());
            // System.
            // getProperty
            // ("user"));
            tmpData.visualAttribute("CA");
            tmpData.xmlContent(null);
            tmpData.id(queryMasterType.getQueryMasterId());
            tmpData.userId(queryMasterType.getUserId());
            // System.getProperty
            // ("user"));
            previousQueries.add(tmpData);
        }

        if (previousQueries.size() == 0) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            });
            return;
        }
        loadPatientSets();
        if (cellStatus.equalsIgnoreCase("")) {
            reset(200, false, false);
        } else if (cellStatus.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
        return;
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
}

From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java

@SuppressWarnings("rawtypes")
private void jBackwardButtonActionPerformed(java.awt.event.ActionEvent evt) {
    /*LoginHelper pms = new LoginHelper();
    try {/*from   w ww  .  jav  a  2s .  c om*/
       PasswordType ptype = new PasswordType();
       ptype.setIsToken(UserInfoBean.getInstance().getUserPasswordIsToken());
       ptype.setTokenMsTimeout(UserInfoBean.getInstance()
       .getUserPasswordTimeout());
       ptype.setValue(UserInfoBean.getInstance().getUserPassword());
       String response = pms.getUserInfo(UserInfoBean.getInstance().getUserName(), ptype, UserInfoBean.getInstance().getSelectedProjectUrl(), 
       UserInfoBean.getInstance().getUserDomain(), false, UserInfoBean.getInstance().getProjectId());
    }
    catch(Exception e) {
       e.printStackTrace();
    }*/

    System.out.println("Loading previous queries for: " + System.getProperty("user"));

    cellStatus = "";
    //String searchStr = jSearchStringTextField.getText();
    int category = jCategoryComboBox.getSelectedIndex();
    int strategy = jContainComboBox.getSelectedIndex();

    curCreationDate = previousQueries.get(0).creationTime();
    ////////////////////////////////////////////////
    SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance();
    Date date = null;
    try {
        date = df.parse(this.jStartTimeTextField.getText());
    } catch (Exception e) {
        e.printStackTrace();
    }
    DTOFactory dtoFactory = new DTOFactory();

    TimeZone tz = Calendar.getInstance().getTimeZone();
    GregorianCalendar cal = new GregorianCalendar(tz);
    cal.setTime(date);
    //cal.get(Calendar.ZONE_OFFSET);
    int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000;
    //log.info("Timezone: "+tz.getID()+" : "+zt_offset);

    //if (startTime() != -1) {
    ConstrainDateType constraindateType = new ConstrainDateType();
    XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR),
            cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH));
    xmlC.setTimezone(zt_offset);//0);//-5*60);
    xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY));
    xmlC.setMinute(cal.get(GregorianCalendar.MINUTE));
    xmlC.setSecond(cal.get(GregorianCalendar.SECOND));
    constraindateType.setValue(xmlC);
    //timeConstrain.setDateFrom(constraindateType);
    //}
    ////////////////////////////////////////////////
    String xmlStr = writePagingQueryXML("", category, strategy, true, xmlC);//curCreationDate);
    // System.out.println(xmlStr);

    String responseStr = null;
    if (System.getProperty("webServiceMethod").equals("SOAP")) {
        responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr);
    } else {
        responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr);
    }

    if (responseStr.equalsIgnoreCase("CellDown")) {
        cellStatus = new String("CellDown");
        return; //"CellDown";
    }

    try {
        JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil();
        JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr);
        ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
        BodyType bt = messageType.getMessageBody();
        MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass(
                bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class);
        for (Condition status : masterResponseType.getStatus().getCondition()) {
            if (status.getType().equals("ERROR"))
                cellStatus = new String("CellDown");
        }
        previousQueries = new ArrayList<QueryMasterData>();
        for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) {
            QueryMasterData tmpData;
            tmpData = new QueryMasterData();
            XMLGregorianCalendar cldr = queryMasterType.getCreateDate();
            tmpData.name(
                    queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay())
                            + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]");
            tmpData.creationTime(cldr);//.clone());
            tmpData.creationTimeStr(
                    addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear())
                            + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond());
            tmpData.tooltip("A query run by " + queryMasterType.getUserId());
            // System.
            // getProperty
            // ("user"));
            tmpData.visualAttribute("CA");
            tmpData.xmlContent(null);
            tmpData.id(queryMasterType.getQueryMasterId());
            tmpData.userId(queryMasterType.getUserId()); // System.getProperty
            // ("user"));
            previousQueries.add(tmpData);
        }

        if (previousQueries.size() == 0) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            });
            return;
        }
        loadPatientSets();
        if (cellStatus.equalsIgnoreCase("")) {
            reset(200, false, true);
        } else if (cellStatus.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
        return;
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
}

From source file:org.openvpms.esci.adapter.map.invoice.UBLInvoice.java

/**
 * Returns the invoice issue date/time.//from  w w  w .j  a va 2 s .  co  m
 *
 * @return the issue date/time
 * @throws ESCIAdapterException if the issue date isn't set
 */
public Date getIssueDatetime() {
    IssueDateType issueDate = getRequired(invoice.getIssueDate(), "IssueDate");
    XMLGregorianCalendar calendar = issueDate.getValue();
    checkRequired(calendar, "IssueDate");

    IssueTimeType issueTime = invoice.getIssueTime();
    if (issueTime != null) {
        XMLGregorianCalendar time = issueTime.getValue();
        if (time != null) {
            calendar.setHour(time.getHour());
            calendar.setMinute(time.getMinute());
            calendar.setSecond(time.getSecond());
            calendar.setMillisecond(time.getMillisecond());
        }
    }
    return calendar.toGregorianCalendar().getTime();
}

From source file:org.talend.components.netsuite.client.model.search.SearchDateFieldAdapter.java

protected XMLGregorianCalendar convertDateTime(String input) {
    String valueToParse = input;//from  ww w  . j av a 2  s . c om
    String dateTimeFormatPattern = dateFormatPattern + " " + timeFormatPattern;
    if (input.length() == dateFormatPattern.length()) {
        dateTimeFormatPattern = dateFormatPattern;
    } else if (input.length() == timeFormatPattern.length()) {
        DateTime dateTime = new DateTime();
        DateTimeFormatter dateFormatter = DateTimeFormat.forPattern(dateFormatPattern);
        valueToParse = dateFormatter.print(dateTime) + " " + input;
    }

    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(dateTimeFormatPattern);

    DateTime dateTime;
    try {
        dateTime = dateTimeFormatter.parseDateTime(valueToParse);
    } catch (IllegalArgumentException e) {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR),
                NetSuiteRuntimeI18n.MESSAGES.getMessage("error.searchDateField.invalidDateTimeFormat",
                        valueToParse));
    }

    XMLGregorianCalendar xts = datatypeFactory.newXMLGregorianCalendar();
    xts.setYear(dateTime.getYear());
    xts.setMonth(dateTime.getMonthOfYear());
    xts.setDay(dateTime.getDayOfMonth());
    xts.setHour(dateTime.getHourOfDay());
    xts.setMinute(dateTime.getMinuteOfHour());
    xts.setSecond(dateTime.getSecondOfMinute());
    xts.setMillisecond(dateTime.getMillisOfSecond());
    xts.setTimezone(dateTime.getZone().toTimeZone().getOffset(dateTime.getMillis()) / 60000);

    return xts;
}