Example usage for org.apache.commons.lang.time DateFormatUtils format

List of usage examples for org.apache.commons.lang.time DateFormatUtils format

Introduction

In this page you can find the example usage for org.apache.commons.lang.time DateFormatUtils format.

Prototype

public static String format(Date date, String pattern) 

Source Link

Document

Formats a date/time into a specific pattern.

Usage

From source file:com.prowidesoftware.swift.utils.SwiftFormatUtils.java

/**
 * @since 6.4//from  w  w  w.  ja  va 2  s.  com
 */
private static String getCalendar(final Calendar date, final String format) {
    if (date != null) {
        return DateFormatUtils.format(date.getTime(), format);
    }
    return null;
}

From source file:au.org.ala.biocache.dto.OccurrenceIndex.java

@JsonIgnore
public Map<String, String> toMap() {
    String sdate = null;// w ww  . j a va 2 s.  c  om
    if (eventDate != null) {
        sdate = DateFormatUtils.format(eventDate, "yyyy-MM-dd");
    }
    Map<String, String> map = new HashMap<String, String>();
    addToMapIfNotNull(map, "id", uuid);
    addToMapIfNotNull(map, "occurrence_id", occurrenceID);
    addToMapIfNotNull(map, "data_hub_uid", arrToString(dataHubUid));
    addToMapIfNotNull(map, "data_hub", dataHub);
    addToMapIfNotNull(map, "institution_uid", institutionUid);
    addToMapIfNotNull(map, "institution_code", raw_institutionCode);
    addToMapIfNotNull(map, "institution_name", institutionName);
    addToMapIfNotNull(map, "collection_uid", collectionUid);
    addToMapIfNotNull(map, "collection_code", raw_collectionCode);
    addToMapIfNotNull(map, "collection_name", collectionName);
    addToMapIfNotNull(map, "catalogue_number", raw_catalogNumber);
    addToMapIfNotNull(map, "taxon_concept_lsid", taxonConceptID);
    addToMapIfNotNull(map, "occurrence_date", sdate);
    addToMapIfNotNull(map, "taxon_name", scientificName);
    addToMapIfNotNull(map, "common_name", vernacularName);
    addToMapIfNotNull(map, "rank", taxonRank);
    addToMapIfNotNull(map, "rank_id", safeIntToString(taxonRankID));
    addToMapIfNotNull(map, "country_code", raw_countryCode);
    addToMapIfNotNull(map, "country", country);
    addToMapIfNotNull(map, "kingdom", kingdom);
    addToMapIfNotNull(map, "phylum", phylum);
    addToMapIfNotNull(map, "class", classs);
    addToMapIfNotNull(map, "order", order);
    addToMapIfNotNull(map, "family", family);
    addToMapIfNotNull(map, "genus", genus);
    addToMapIfNotNull(map, "genus_guid", genusGuid);
    addToMapIfNotNull(map, "species", species);
    addToMapIfNotNull(map, "species_guid", speciesGuid);
    addToMapIfNotNull(map, "subspecies", subspecies);
    addToMapIfNotNull(map, "subspecies_guid", subspeciesGuid);
    addToMapIfNotNull(map, "state", stateProvince);
    addToMapIfNotNull(map, "latitude", safeDblToString(decimalLatitude));
    addToMapIfNotNull(map, "longitude", safeDblToString(decimalLongitude));
    addToMapIfNotNull(map, "year", year);
    addToMapIfNotNull(map, "month", month);
    addToMapIfNotNull(map, "basis_of_record", basisOfRecord);
    addToMapIfNotNull(map, "type_status", typeStatus);
    addToMapIfNotNull(map, "location_remarks", raw_locationRemarks);
    addToMapIfNotNull(map, "occurrence_remarks", raw_occurrenceRemarks);
    addToMapIfNotNull(map, "lft", safeIntToString(left));
    addToMapIfNotNull(map, "rgt", safeIntToString(right));
    addToMapIfNotNull(map, "ibra", ibra);
    addToMapIfNotNull(map, "imcra", imcra);
    addToMapIfNotNull(map, "places", lga);
    addToMapIfNotNull(map, "data_provider_uid", dataProviderUid);
    addToMapIfNotNull(map, "data_provider", dataProviderName);
    addToMapIfNotNull(map, "data_resource_uid", dataResourceUid);
    addToMapIfNotNull(map, "data_resource", dataResourceName);
    addToMapIfNotNull(map, "assertions", arrToString(assertions));
    addToMapIfNotNull(map, "user_assertions", hasUserAssertions);
    addToMapIfNotNull(map, "species_group", arrToString(speciesGroups));
    addToMapIfNotNull(map, "image_url", image);
    addToMapIfNotNull(map, "geospatial_kosher", geospatialKosher);
    addToMapIfNotNull(map, "taxonomic_kosher", taxonomicKosher);
    addToMapIfNotNull(map, "raw_taxon_name", raw_scientificName);
    addToMapIfNotNull(map, "raw_basis_of_record", raw_basisOfRecord);
    addToMapIfNotNull(map, "raw_type_status", raw_typeStatus);
    addToMapIfNotNull(map, "raw_common_name", raw_vernacularName);
    addToMapIfNotNull(map, "lat_long", latLong);
    addToMapIfNotNull(map, "point-1", point1);
    addToMapIfNotNull(map, "point-0.1", point01);
    addToMapIfNotNull(map, "point-0.01", point001);
    addToMapIfNotNull(map, "point-0.001", point0001);
    addToMapIfNotNull(map, "point-0.0001", point00001);
    addToMapIfNotNull(map, "names_and_lsid", namesLsid);
    addToMapIfNotNull(map, "multimedia", arrToString(multimedia));
    addToMapIfNotNull(map, "collector", collector);
    addToMapIfNotNull(map, "collectors", arrToString(collectors));
    addToMapIfNotNull(map, "record_number", recordNumber);
    addToMapIfNotNull(map, "occurrence_details", occurrenceDetails);
    addToMapIfNotNull(map, "rights", rights);
    addToMapIfNotNull(map, "photographer_s", photographer);
    return map;
}

From source file:gtu._work.etc.HotnoteMakerUI.java

private void initGUI() {
    try {//from w  w  w .ja  v a  2 s .c o m
        ToolTipManager.sharedInstance().setInitialDelay(0);
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("hott notes - checklist", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(612, 348));
                    {
                        checkListArea = new JTextArea();
                        jScrollPane1.setViewportView(checkListArea);
                        checkListArea.addMouseListener(new MouseAdapter() {

                            String randomColor() {
                                StringBuilder sb = new StringBuilder().append("#");
                                for (int ii = 0; ii < 6; ii++) {
                                    sb.append(RandomUtil.randomChar('a', 'b', 'c', 'd', 'f', '0', '1', '2', '3',
                                            '4', '5', '6', '7', '8', '9'));
                                }
                                return sb.toString();
                            }

                            void saveXml(Document document, File file) {
                                OutputFormat format = OutputFormat.createPrettyPrint();
                                format.setEncoding("utf-16");
                                XMLWriter writer = null;
                                try {
                                    writer = new XMLWriter(new FileWriter(file), format);
                                    writer.write(document);
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                } finally {
                                    if (writer != null) {
                                        try {
                                            writer.close();
                                        } catch (IOException e) {
                                            JCommonUtil.handleException(e);
                                        }
                                    }
                                }
                            }

                            public void mouseClicked(MouseEvent evt) {
                                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                    return;
                                }

                                if (StringUtils.isEmpty(checkListArea.getText())) {
                                    JCommonUtil
                                            ._jOptionPane_showMessageDialog_error("checklist area is empty!");
                                    return;
                                }

                                File file = JCommonUtil._jFileChooser_selectFileOnly_saveFile();
                                if (file == null) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("file is not correct!");
                                    return;
                                }

                                //XXX
                                StringTokenizer tok = new StringTokenizer(checkListArea.getText(), "\t\n\r\f");
                                List<String> list = new ArrayList<String>();
                                String tmp = null;
                                for (; tok.hasMoreElements();) {
                                    tmp = ((String) tok.nextElement()).trim();
                                    System.out.println(tmp);
                                    list.add(tmp);
                                }
                                //XXX

                                Document document = DocumentHelper.createDocument();
                                Element rootHot = document.addElement("hottnote");
                                rootHot.addAttribute("creationtime",
                                        new Timestamp(System.currentTimeMillis()).toString());
                                rootHot.addAttribute("lastmodified",
                                        new Timestamp(System.currentTimeMillis()).toString());
                                rootHot.addAttribute("type", "checklist");
                                //appearence
                                Element appearenceE = rootHot.addElement("appearence");
                                appearenceE.addAttribute("alpha", "204");
                                Element fontE = appearenceE.addElement("font");
                                fontE.addAttribute("face", "Default");
                                fontE.addAttribute("size", "0");
                                Element styleE = appearenceE.addElement("style");
                                styleE.addElement("bg2color").addAttribute("color", randomColor());
                                styleE.addElement("bgcolor").addAttribute("color", randomColor());
                                styleE.addElement("textcolor").addAttribute("color", randomColor());
                                styleE.addElement("titlecolor").addAttribute("color", randomColor());
                                //behavior
                                rootHot.addElement("behavior");
                                //content
                                Element contentE = rootHot.addElement("content");
                                Element checklistE = contentE.addElement("checklist");
                                for (String val : list) {
                                    checklistE.addElement("item").addCDATA(val);
                                }
                                //desktop
                                Element desktopE = rootHot.addElement("desktop");
                                desktopE.addElement("position").addAttribute("x", RandomUtil.numberStr(3))
                                        .addAttribute("y", RandomUtil.numberStr(3));
                                desktopE.addElement("size").addAttribute("height", "200").addAttribute("width",
                                        "200");
                                //title
                                Element titleE = rootHot.addElement("title");
                                titleE.addCDATA(StringUtils.defaultIfEmpty(checkListTitle.getText(),
                                        DateFormatUtils.format(System.currentTimeMillis(), "dd/MM/yyyy")));

                                if (!file.getName().toLowerCase().endsWith(".hottnote")) {
                                    file = new File(file.getParentFile(), file.getName() + ".hottnote");
                                }

                                saveXml(document, file);
                                JCommonUtil._jOptionPane_showMessageDialog_info("completed!\n" + file);
                            }
                        });
                    }
                }
                {
                    checkListTitle = new JTextField();
                    checkListTitle.setToolTipText("title");
                    jPanel1.add(checkListTitle, BorderLayout.NORTH);
                }
            }
        }
        pack();
        this.setSize(633, 415);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:javacommon.excel.ExcelReader.java

/**
 * ???//from   w ww.j  ava  2  s  . com
 *
 * @param c ?
 * @return
 */
private String getCellStringValue(Cell c) {
    if (c == null) {
        return "";
    }
    String value = null;
    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMaximumFractionDigits(12);
    switch (c.getCellType()) {
    case Cell.CELL_TYPE_BOOLEAN:
        value = String.valueOf(c.getBooleanCellValue());
        break;
    case Cell.CELL_TYPE_NUMERIC:
        if (DateUtil.isCellDateFormatted(c)) {
            return DateFormatUtils.ISO_DATE_FORMAT.format(c.getDateCellValue());
        } else if ("@".equals(c.getCellStyle().getDataFormatString())) {
            value = nf.format(c.getNumericCellValue());
        } else if ("General".equals(c.getCellStyle().getDataFormatString())) {
            value = nf.format(c.getNumericCellValue());
        } else if (ArrayUtils.contains(ExcelConstants.DATE_PATTERNS, c.getCellStyle().getDataFormatString())) {
            value = DateFormatUtils.format(HSSFDateUtil.getJavaDate(c.getNumericCellValue()),
                    c.getCellStyle().getDataFormatString());
        } else {
            value = nf.format(c.getNumericCellValue());
        }
        break;
    case Cell.CELL_TYPE_STRING:
        value = c.getStringCellValue();
        break;
    case Cell.CELL_TYPE_FORMULA:
        value = c.getCellFormula();
        break;
    }
    return value == null ? "" : value.trim();
}

From source file:com.intuit.tank.notification.NotificationContextBuilder.java

private String cleanDate(Date d) {
    return d == null ? NotificationContextBuilder.N_A
            : DateFormatUtils.format(d, TankConstants.DATE_FORMAT_WITH_TIMEZONE);
}

From source file:net.duckling.ddl.service.mail.thread.EmailNoticeJob.java

private String buildJobName(Date currentDay) {
    return "emailNotice" + DateFormatUtils.format(currentDay, "yyyy-MM-dd");
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.RoomSiteViewerDispatchAction.java

public ActionForward roomViewer(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    User userView = getUserView(request);

    String roomName = request.getParameter("roomName");
    if (roomName == null) {
        roomName = (String) request.getAttribute("roomName");
    }//  w  w  w .ja  v a 2 s  . c  om
    request.setAttribute("roomName", roomName);
    RoomKey roomKey = null;

    if (roomName != null) {
        roomKey = new RoomKey(roomName);

        ISiteComponent bodyComponent = new InfoSiteRoomTimeTable();
        DynaActionForm indexForm = (DynaActionForm) form;
        Integer indexWeek = (Integer) indexForm.get("indexWeek");
        // Integer executionPeriodID = (Integer)
        // indexForm.get("selectedExecutionPeriodID");
        String executionPeriodIDString = request.getParameter("selectedExecutionPeriodID");
        if (executionPeriodIDString == null) {
            executionPeriodIDString = (String) request.getAttribute("selectedExecutionPeriodID");
        }
        String executionPeriodID = (executionPeriodIDString != null) ? executionPeriodIDString : null;
        if (executionPeriodID == null) {
            try {
                // executionPeriodID = (Integer)
                // indexForm.get("selectedExecutionPeriodID");
                executionPeriodID = indexForm.get("selectedExecutionPeriodID").equals("") ? null
                        : (String) indexForm.get("selectedExecutionPeriodID");
            } catch (IllegalArgumentException ex) {
            }
        }
        Calendar today = new DateMidnight().toCalendar(null);
        ArrayList weeks = new ArrayList();

        InfoExecutionPeriod executionPeriod;
        if (executionPeriodID == null) {
            executionPeriod = ReadCurrentExecutionPeriod.run();
            executionPeriodID = executionPeriod.getExternalId();
            try {
                indexForm.set("selectedExecutionPeriodID", executionPeriod.getExternalId().toString());
            } catch (IllegalArgumentException ex) {
            }
        } else {
            executionPeriod = ReadExecutionPeriodByOID.run(executionPeriodID);
        }

        // weeks
        Calendar begin = Calendar.getInstance();
        begin.setTime(executionPeriod.getBeginDate());
        Calendar end = Calendar.getInstance();
        end.setTime(executionPeriod.getEndDate());
        ArrayList weeksLabelValueList = new ArrayList();
        begin.add(Calendar.DATE, Calendar.MONDAY - begin.get(Calendar.DAY_OF_WEEK));
        int i = 0;
        boolean selectedWeek = false;
        while (begin.before(end) || begin.before(Calendar.getInstance())) {
            Calendar day = Calendar.getInstance();
            day.setTimeInMillis(begin.getTimeInMillis());
            weeks.add(day);
            String beginWeekString = DateFormatUtils.format(begin.getTime(), "dd/MM/yyyy");
            begin.add(Calendar.DATE, 5);
            String endWeekString = DateFormatUtils.format(begin.getTime(), "dd/MM/yyyy");
            weeksLabelValueList.add(
                    new LabelValueBean(beginWeekString + " - " + endWeekString, new Integer(i).toString()));
            begin.add(Calendar.DATE, 2);
            if (!selectedWeek && indexWeek == null && Calendar.getInstance().before(begin)) {
                indexForm.set("indexWeek", new Integer(i));
                selectedWeek = true;
            }
            i++;
        }

        final Collection<ExecutionSemester> executionSemesters = rootDomainObject.getExecutionPeriodsSet();
        final List<LabelValueBean> executionPeriodLabelValueBeans = new ArrayList<LabelValueBean>();
        for (final ExecutionSemester ep : executionSemesters) {
            if (ep.getState().equals(PeriodState.OPEN) || ep.getState().equals(PeriodState.CURRENT)) {
                executionPeriodLabelValueBeans.add(new LabelValueBean(
                        ep.getName() + " " + ep.getExecutionYear().getYear(), ep.getExternalId().toString()));
            }
        }
        request.setAttribute(PresentationConstants.LABELLIST_EXECUTIONPERIOD, executionPeriodLabelValueBeans);

        request.setAttribute(PresentationConstants.LABELLIST_WEEKS, weeksLabelValueList);
        if (indexWeek != null) {
            final int xpto = indexWeek.intValue();
            if (xpto < weeks.size()) {
                today = (Calendar) weeks.get(xpto);
            } else {
                today = (Calendar) weeks.iterator().next();
                indexForm.set("indexWeek", new Integer(0));
            }
        }

        try {
            SiteView siteView = (SiteView) RoomSiteComponentServiceByExecutionPeriodID.run(bodyComponent,
                    roomKey, today, executionPeriodID);

            request.setAttribute("siteView", siteView);

        } catch (NonExistingServiceException e) {
            throw new NonExistingActionException(e);
        } catch (FenixServiceException e) {
            throw new FenixActionException(e);
        }
        return mapping.findForward("roomViewer");
    }
    throw new FenixActionException();

}

From source file:com.netsteadfast.greenstep.bsc.action.HistoryItemScoreReportContentQueryAction.java

private String getChangeDateVal() throws ParseException {
    String dateVal = this.getFields().get("dateVal");
    String dateChangeStatus = this.getFields().get("dateChangeStatus");
    String sysNowDate = super.getNowDate().replaceAll("/", "");
    Date dateValObj = DateUtils.parseDate(dateVal, new String[] { "yyyyMMdd" });
    if ("next".equals(dateChangeStatus)) {
        if (Integer.parseInt(dateVal) >= Integer.parseInt(sysNowDate)) {
            dateVal = sysNowDate;/*from w ww .j a  v a2s  .  c  o m*/
        } else {
            Date nexDate = DateUtils.addDays(dateValObj, 1);
            dateVal = DateFormatUtils.format(nexDate, "yyyyMMdd");
        }
    }
    if ("prev".equals(dateChangeStatus)) {
        Date nexDate = DateUtils.addDays(dateValObj, -1);
        dateVal = DateFormatUtils.format(nexDate, "yyyyMMdd");
    }
    return dateVal;
}

From source file:javacommon.excel.ExcelReader.java

/**
 * ???//from   w  ww  .ja  v a 2  s  . co  m
 *
 * @param c ?
 * @return
 */
private String getCellStringFormatValue(Cell c) {
    if (c == null) {
        return "";
    }
    String value = null;
    NumberFormat nf = NumberFormat.getInstance();
    nf.setGroupingUsed(false);
    nf.setMaximumFractionDigits(12);
    switch (c.getCellType()) {
    case Cell.CELL_TYPE_BOOLEAN:
        value = String.valueOf(c.getBooleanCellValue());
        break;
    case Cell.CELL_TYPE_NUMERIC:
        if (DateUtil.isCellDateFormatted(c)) {
            return DateFormatUtils.ISO_DATE_FORMAT.format(c.getDateCellValue());
        } else if ("@".equals(c.getCellStyle().getDataFormatString())) {
            value = nf.format(c.getNumericCellValue());
        } else if ("General".equals(c.getCellStyle().getDataFormatString())) {
            value = nf.format(c.getNumericCellValue());
        } else if (ArrayUtils.contains(ExcelConstants.DATE_PATTERNS, c.getCellStyle().getDataFormatString())) {
            value = DateFormatUtils.format(HSSFDateUtil.getJavaDate(c.getNumericCellValue()),
                    c.getCellStyle().getDataFormatString());
        } else {
            value = nf.format(c.getNumericCellValue());
        }
        break;
    case Cell.CELL_TYPE_STRING:
        value = c.getStringCellValue();
        break;
    case Cell.CELL_TYPE_FORMULA:
        return c.getCellFormula();
    }
    return value == null ? "" : value.trim();
}

From source file:com.turborep.turbotracker.sales.service.Salesserviceimpl.java

@Override
public ArrayList<?> getUpcoming(SalesRepBean theSalesRep) {
    itsLogger.debug("Retrieving getUpcoming");
    Integer aSalesRepId = theSalesRep.getSalesRepId();
    if (aSalesRepId == 0) {
        aSalesRepId = null;//  w w w . j a v a  2s  .c  om
    }
    Integer customerID = theSalesRep.getRxMasterID();
    if (customerID == 0) {
        customerID = null;
    }
    String aName = "";
    String aname2 = "";
    if (aSalesRepId != null && aSalesRepId != -1) {
        aName = "WHERE (" + " joMaster.cuAssignmentID0 = " + aSalesRepId + " OR "
                + " joMaster.cuAssignmentID1 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID2 = "
                + aSalesRepId + " OR " + " joMaster.cuAssignmentID3 = " + aSalesRepId + " OR "
                + " joMaster.cuAssignmentID4 = " + aSalesRepId + " OR " + " joMaster.cuAssignmentID5 = "
                + aSalesRepId + " OR " + " joMaster.cuAssignmentID6 = " + aSalesRepId
                + " ) AND joMaster.jobStatus in (0,-4,1,6) ";

        // aname2 = "WHERE joMaster.jobStatus in (0,-4,1,6) )";

        aname2 = "WHERE " + "(cu.cuAssignmentID0 = " + aSalesRepId + " OR " + "cu.cuAssignmentID1 = "
                + aSalesRepId + " OR " + "cu.cuAssignmentID2 = " + aSalesRepId + " OR "
                + "cu.cuAssignmentID3 = " + aSalesRepId + " OR " + "cu.cuAssignmentID4 = " + aSalesRepId
                + ")) AND joMaster.jobStatus in (0,-4,1,6)";
    } else {

        aName = "WHERE joMaster.jobStatus in (0,-4,1,6) ";
        aname2 = "WHERE joMaster.jobStatus in (0,-4,1,6) )";
    }
    String aUpcomingQry = "SELECT DISTINCT BidDate, Description, JobNumber, "
            + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID0  AND LoginName != 'admin' ) AS asignedSales, "
            + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID1  AND LoginName != 'admin' ) AS asignedCust, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCustomerID ) AS allCust, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCategory1  ) AS architect, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCategory2 ) AS engineer, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCategory3 ) AS generalContract,joMaster.joMasterID  "
            + " FROM joMaster    LEFT JOIN joBidder ON (joMaster.joMasterID=joBidder.joMasterID) " + aName
            + " AND BidDate >= CURDATE() ";
    if (customerID != null) {
        aUpcomingQry = aUpcomingQry + " AND joBidder.rxMasterID=" + customerID;
    }

    aUpcomingQry = aUpcomingQry + " UNION " + "SELECT DISTINCT BidDate, Description, JobNumber, "
            + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID0  AND LoginName != 'admin' ) AS asignedSales, "
            + " (SELECT FullName FROM tsUserLogin Where userLoginId = joMaster.cuAssignmentID1  AND LoginName != 'admin' ) AS asignedCust, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCustomerID ) AS allCust, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCategory1  ) AS architect, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCategory2 ) AS engineer, "
            + " (SELECT NAME FROM rxMaster WHERE rxMasterID = joMaster.rxCategory3 ) AS generalContract,joMaster.joMasterID  "
            + " FROM joMaster LEFT JOIN joBidder ON (joMaster.joMasterID=joBidder.joMasterID) WHERE joMaster.joMasterId IN (SELECT jb.joMasterId FROM joBidder jb JOIN cuMaster cu ON cu.cuMasterId = jb.rxMasterId "
            + " " + aname2 + "" + " AND BidDate >= CURDATE() ";

    if (customerID != null) {
        aUpcomingQry = aUpcomingQry + " AND joBidder.rxMasterID=" + customerID;
    }

    if (theSalesRep.getSortcolumn() != null && theSalesRep.getSortby() != null) {
        aUpcomingQry = aUpcomingQry + " ORDER BY " + theSalesRep.getSortcolumn() + " "
                + theSalesRep.getSortby();
    } else {
        aUpcomingQry = aUpcomingQry + " ORDER BY BidDate DESC ";
    }

    Session aSession = null;
    ArrayList<JobsBean> aComingQry = new ArrayList<JobsBean>();
    try {
        JobsBean aUpcomingJobs = null;
        aSession = itsSessionFactory.openSession();
        Query aQuery = aSession.createSQLQuery(aUpcomingQry);
        Iterator<?> aIterator = aQuery.list().iterator();
        while (aIterator.hasNext()) {
            aUpcomingJobs = new JobsBean();
            Object[] aObj = (Object[]) aIterator.next();
            if (aObj[0] != null) {
                aUpcomingJobs.setBidDate((String) DateFormatUtils.format((Date) aObj[0], "MM/dd/yyyy"));
            }
            aUpcomingJobs.setJobName((String) aObj[1]);
            aUpcomingJobs.setJobNo((String) aObj[2]);
            if (aObj[3] != null) {
                aUpcomingJobs.setAssignedSalesman((String) aObj[3].toString());
            }
            if (aObj[4] != null) {
                aUpcomingJobs.setAssignedCustomers((String) aObj[4].toString());
            }
            if (aObj[5] != null) {
                aUpcomingJobs.setAllCustomer((String) aObj[5].toString());
            }
            if (aObj[6] != null) {
                aUpcomingJobs.setArchitect((String) aObj[6].toString());
            }
            if (aObj[7] != null) {
                aUpcomingJobs.setEngineer((String) aObj[7].toString());
            }
            if (aObj[8] != null) {
                aUpcomingJobs.setGeneralContractor((String) aObj[8].toString());
            }
            aUpcomingJobs.setJoMasterId((Integer) aObj[9]);
            aComingQry.add(aUpcomingJobs);
        }
    } catch (Exception e) {
        itsLogger.error(e.getMessage(), e);
    } finally {
        aSession.flush();
        aSession.close();
        aUpcomingQry = null;
    }
    return aComingQry;
}