List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:fll.scheduler.SchedulerUI.java
private void loadScheduleDescription(final File file) { final Properties properties = new Properties(); try (final Reader reader = new InputStreamReader(new FileInputStream(file), Utilities.DEFAULT_CHARSET)) { properties.load(reader);/*from ww w. j ava 2 s . c o m*/ } catch (final IOException e) { final Formatter errorFormatter = new Formatter(); errorFormatter.format("Error loading file: %s", e.getMessage()); LOGGER.error(errorFormatter, e); JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error loading file", JOptionPane.ERROR_MESSAGE); return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug(properties.toString()); } try { final SolverParams params = new SolverParams(); params.load(properties); mScheduleDescriptionEditor.setParams(params); } catch (final ParseException pe) { final Formatter errorFormatter = new Formatter(); errorFormatter.format("Error parsing file: %s", pe.getMessage()); LOGGER.error(errorFormatter, pe); JOptionPane.showMessageDialog(SchedulerUI.this, errorFormatter, "Error parsing file", JOptionPane.ERROR_MESSAGE); return; } mScheduleDescriptionFile = file; mDescriptionFilename.setText(file.getName()); }
From source file:org.egov.works.web.actions.estimate.SearchEstimateAction.java
@Override public SearchQuery prepareQuery(final String sortField, final String sortOrder) { // prepare the query string List<Object> paramList = new ArrayList<Object>(); String query = null;/*w ww . j a va 2s. c o m*/ String countQuery = null; String baseQuery = null; // String OrderBy = null; final StringBuilder sb = new StringBuilder(500); Map queryAndParms = null; if (SEARCH_ESTIMATE_FOR_MILESTONE.equalsIgnoreCase(source) || VIEW_MILESTONE.equalsIgnoreCase(source) || CANCEL_MILESTONE.equalsIgnoreCase(source)) { queryAndParms = getEstimateForMilestoneQuery(); paramList = (List<Object>) queryAndParms.get("params"); query = (String) queryAndParms.get("query"); // countQuery="select count(distinct woe.id) " + query; if (CANCEL_MILESTONE.equalsIgnoreCase(source) || SEARCH_ESTIMATE_FOR_MILESTONE.equalsIgnoreCase(source)) countQuery = "select count(distinct woe.id) " + query; if (CANCEL_MILESTONE.equalsIgnoreCase(source)) query = "select distinct woe " + query; if (VIEW_MILESTONE.equalsIgnoreCase(source)) { countQuery = "select count(woe.id) " + query; query = "select woe , milestone , trackMilestone " + query; } } else { baseQuery = "from AbstractEstimate as ae where ae.parent is null "; boolean isError = false; /* * OrderBy = "asc"; if (selectedorder) OrderBy = "desc"; */ if (SEARCH_ESTIMATE_FOR_WO.equals(source)) { if (StringUtils.isNotBlank(status)) { sb.append(baseQuery); sb.append(" and ( ae.id in ( " + " ( select tr.tenderEstimate.abstractEstimate.id " + " from TenderResponse tr where tr.egwStatus.code=? ) ) or ae.id in ( " + " select wd.estimate.id from WorksPackageDetails wd where wd.worksPackage.id in " + " (select tr.tenderEstimate.worksPackage.id from TenderResponse tr " + " where tr.tenderEstimate.abstractEstimate.id=null and tr.tenderEstimate.worksPackage.id!=null " + " and tr.egwStatus.code=? )))" + " and ae.id not in (select wo.abstractEstimate.id from WorkOrder wo where wo.parent is null)"); paramList.add(status); paramList.add(status); } } else if (StringUtils.isNotBlank(getStatus()) && (getStatus().equals(AbstractEstimate.EstimateStatus.ADMIN_SANCTIONED.toString()) || getStatus().equals(AbstractEstimate.EstimateStatus.CANCELLED.toString()))) { sb.append(baseQuery); sb.append("and ae.egwStatus.code = ?"); paramList.add(getStatus()); } else if (StringUtils.isNotBlank(getStatus()) && !getStatus().equals("-1")) { sb.append(baseQuery); sb.append("and ae.egwStatus.code=? "); paramList.add(getStatus()); } else if (StringUtils.isNotBlank(getStatus()) && getStatus().equals("-1")) { sb.append(baseQuery); sb.append("and ae.egwStatus.code not in ('NEW')"); } if (getExecDept() != null && getExecDept() != -1) { sb.append(" and ae.executingDepartment.id= ? "); paramList.add(getExecDept()); } if (getExpenditureType() != -1) { sb.append(" and ae.natureOfWork.id= ? "); paramList.add(Long.valueOf(getExpenditureType())); } if (StringUtils.isNotBlank(getEstimatenumber())) { sb.append(" and ae.estimateNumber like ? "); paramList.add("%" + getEstimatenumber() + "%"); } if (StringUtils.isNotBlank(projCode)) { sb.append(" and ae.projectCode.code like ? "); paramList.add("%" + projCode + "%"); } if (estimateCreatedBy != null && estimateCreatedBy != -1) { sb.append(" and ae.createdBy.id=? "); paramList.add(estimateCreatedBy); } if (estimates.getCategory() != null) { sb.append(" and ae.category.id= ? "); paramList.add(estimates.getCategory().getId()); } if (estimates.getParentCategory() != null) { sb.append(" and ae.parentCategory.id= ? "); paramList.add(estimates.getParentCategory().getId()); } if (estimates.getDescription() != null && StringUtils.isNotBlank(estimates.getDescription())) { sb.append(" and UPPER(ae.description) like ? "); paramList.add("%" + estimates.getDescription().toUpperCase() + "%"); } if (StringUtils.isNotBlank(wpdate)) { Date workspacDate = null; final SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy", new Locale("en", "IN")); try { workspacDate = formatter.parse(wpdate); } catch (final ParseException e) { isError = true; logger.error("Date Conversion Error :" + e.getMessage()); addFieldError("parse exception", "Date Conversion Error"); } sb.append(" and ae.approvedDate <= ? "); paramList.add(workspacDate); } if ("wp".equals(source) && !isError) sb.append( " and ae.id not in(select tr.tenderEstimate.abstractEstimate.id from TenderResponse tr where " + "tr.egwStatus.code !='CANCELLED' and tr.tenderEstimate.abstractEstimate is not null and ae.id=tr.tenderEstimate.abstractEstimate.id)" + " and ae.id not in(select wpd.estimate.id from WorksPackageDetails wpd where wpd.estimate.id=ae.id " + " and wpd.worksPackage.egwStatus.code !='CANCELLED')"); if ("createNegotiationNew".equals(source) && !isError) sb.append( " and ae.id not in(select tr.tenderEstimate.abstractEstimate.id from TenderResponse tr where " + "tr.egwStatus.code !='CANCELLED' and tr.tenderEstimate.abstractEstimate is not null and ae.id=tr.tenderEstimate.abstractEstimate.id)" + " and ae.id not in(select tr.tenderEstimate.abstractEstimate.id from TenderResponse tr where " + "tr.egwStatus.code ='NEW' and tr.tenderEstimate.abstractEstimate.id is not null)" + " and ae.id not in(select wpd.estimate.id from WorksPackageDetails wpd where wpd.estimate.id=ae.id)"); if (SEARCH_ESTIMATE_FOR_WO.equals(source)) { if (fromDate != null && toDate == null) setToDate(new Date()); if (toDate != null && fromDate == null) { sb.append(" and ae.estimateDate <= ? "); paramList.add(toDate); } } else { if (fromDate != null && toDate == null) addFieldError("enddate", getText("search.endDate.null")); if (toDate != null && fromDate == null) addFieldError("startdate", getText("search.startDate.null")); } if (!DateUtils.compareDates(getToDate(), getFromDate())) addFieldError("enddate", getText("greaterthan.endDate.fromDate")); if (fromDate != null && toDate != null && getFieldErrors().isEmpty()) { sb.append(" and ae.estimateDate between ? and ? "); paramList.add(fromDate); paramList.add(toDate); } // if (sb.length() > 0 && !isError && getFieldErrors().isEmpty() && !"menu".equalsIgnoreCase(option)) // sb.append(" group by ae.egwStatus.code, ae.id order by ae.egwStatus.code " + OrderBy + " "); query = sb.toString(); countQuery = "select count(distinct ae.id) " + query; } return new SearchQueryHQL(query, countQuery, paramList); }
From source file:edu.cornell.kfs.fp.batch.service.impl.AdvanceDepositServiceImpl.java
public boolean loadFile(String fileName, PhysicalFlatFileInformation physicalFlatFileInformation) { boolean valid = true; byte[] fileByteContent = safelyLoadFileBytes(fileName); if (LOG.isInfoEnabled()) { LOG.info("Attempting to parse the file "); }/*from w ww .j a v a 2 s . c om*/ Object parsedObject; try { parsedObject = batchInputFileService.parse(batchInputFileType, fileByteContent); } catch (org.kuali.kfs.sys.exception.ParseException e) { LOG.error("Error parsing batch file: " + e.getMessage()); FlatFileInformation fileInformation = new FlatFileInformation(); fileInformation.addFileInfoMessage("Unable to process file" + StringUtils.substringAfterLast(fileName, "\\") + "." + e.getMessage()); physicalFlatFileInformation.getFlatFileInfomationList().add(fileInformation); return false; } if (parsedObject != null) { valid = validate(parsedObject); copyAllMessage(parsedObject, physicalFlatFileInformation); if (valid) { loadAchIncomeTransactions(parsedObject); } } return valid; }
From source file:net.pms.util.Rational.java
/** * Parses the specified {@link String} and returns a {@link BigDecimal} * using the specified {@link DecimalFormat}. {@code value} is expected to * be without leading or trailing whitespace. If {@code value} is blank, * {@code null} will be returned.//from w w w .j ava2 s . c o m * * @param value the {@link String} to parse. * @param decimalFormat the {@link DecimalFormat} to use when parsing. * @return The resulting {@link BigDecimal}. * @throws NumberFormatException If {@code value} cannot be parsed. */ @Nullable public static BigDecimal parseBigDecimal(@Nullable String value, @Nullable DecimalFormat decimalFormat) { if (StringUtils.isBlank(value)) { return null; } if (decimalFormat != null) { decimalFormat.setParseBigDecimal(true); try { return (BigDecimal) decimalFormat.parseObject(value); } catch (ParseException e) { throw new NumberFormatException("Unable to parse \"" + value + "\": " + e.getMessage()); } } return new BigDecimal(value); }
From source file:com.topsec.tsm.sim.report.util.ReportUiUtil.java
public static Long getSEcount(String sTime, String eTime) { SimpleDateFormat smpFmt1 = new SimpleDateFormat(ReportUiConfig.dFormat1); try {/*from w ww . j a va2 s. c o m*/ return (smpFmt1.parse(eTime).getTime() - smpFmt1.parse(sTime).getTime()) / 1000; } catch (ParseException e) { log.error("Error:" + e.getMessage()); e.printStackTrace(); } return null; }
From source file:org.egov.stms.transactions.service.SewerageApplicationDetailsService.java
public void updateIndexes(final SewerageApplicationDetails sewerageApplicationDetails) { final SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); try {//w w w. j ava 2 s.c o m if (sewerageApplicationDetails.getConnection() != null && sewerageApplicationDetails.getConnection().getExecutionDate() != null) { final String executionDate = myFormat .format(sewerageApplicationDetails.getConnection().getExecutionDate()); sewerageApplicationDetails.getConnection().setExecutionDate(myFormat.parse(executionDate)); } if (sewerageApplicationDetails.getDisposalDate() != null) { final String disposalDate = myFormat.format(sewerageApplicationDetails.getDisposalDate()); sewerageApplicationDetails.setDisposalDate(myFormat.parse(disposalDate)); } if (sewerageApplicationDetails.getApplicationDate() != null) { final String applicationDate = myFormat.format(sewerageApplicationDetails.getApplicationDate()); sewerageApplicationDetails.setApplicationDate(myFormat.parse(applicationDate)); } if (sewerageApplicationDetails.getEstimationDate() != null) { final String estimationDate = myFormat.format(sewerageApplicationDetails.getEstimationDate()); sewerageApplicationDetails.setEstimationDate(myFormat.parse(estimationDate)); } if (sewerageApplicationDetails.getWorkOrderDate() != null) { final String workOrderDate = myFormat.format(sewerageApplicationDetails.getWorkOrderDate()); sewerageApplicationDetails.setWorkOrderDate(myFormat.parse(workOrderDate)); } if (sewerageApplicationDetails.getClosureNoticeDate() != null) { final String closureNoticeDate = myFormat.format(sewerageApplicationDetails.getClosureNoticeDate()); sewerageApplicationDetails.setClosureNoticeDate(myFormat.parse(closureNoticeDate)); } } catch (final ParseException e) { LOG.error("Exception parsing Date " + e.getMessage()); } // Pending : Need to make Rest API call to get assessmentdetails final AssessmentDetails assessmentDetails = sewerageTaxUtils.getAssessmentDetailsForFlag( sewerageApplicationDetails.getConnectionDetail().getPropertyIdentifier(), PropertyExternalService.FLAG_FULL_DETAILS); if (LOG.isDebugEnabled()) LOG.debug(" updating Indexes Started... "); Iterator<OwnerName> ownerNameItr = null; if (null != assessmentDetails.getOwnerNames()) ownerNameItr = assessmentDetails.getOwnerNames().iterator(); final StringBuilder consumerName = new StringBuilder(); final StringBuilder mobileNumber = new StringBuilder(); Assignment assignment = null; User user = null; final StringBuilder aadharNumber = new StringBuilder(); if (null != ownerNameItr && ownerNameItr.hasNext()) { final OwnerName primaryOwner = ownerNameItr.next(); consumerName.append(primaryOwner.getOwnerName() != null ? primaryOwner.getOwnerName() : ""); mobileNumber.append(primaryOwner.getMobileNumber() != null ? primaryOwner.getMobileNumber() : ""); aadharNumber.append(primaryOwner.getAadhaarNumber() != null ? primaryOwner.getAadhaarNumber() : ""); while (ownerNameItr.hasNext()) { final OwnerName secondaryOwner = ownerNameItr.next(); consumerName.append(",") .append(secondaryOwner.getOwnerName() != null ? secondaryOwner.getOwnerName() : ""); mobileNumber.append(",") .append(secondaryOwner.getMobileNumber() != null ? secondaryOwner.getMobileNumber() : ""); aadharNumber.append(",") .append(secondaryOwner.getAadhaarNumber() != null ? secondaryOwner.getAadhaarNumber() : ""); } } List<Assignment> asignList = null; if (sewerageApplicationDetails.getState() != null && sewerageApplicationDetails.getState().getOwnerPosition() != null) { assignment = assignmentService.getPrimaryAssignmentForPositionAndDate( sewerageApplicationDetails.getState().getOwnerPosition().getId(), new Date()); if (assignment != null) { asignList = new ArrayList<>(); asignList.add(assignment); } else if (assignment == null) asignList = assignmentService.getAssignmentsForPosition( sewerageApplicationDetails.getState().getOwnerPosition().getId(), new Date()); if (!asignList.isEmpty()) user = userService.getUserById(asignList.get(0).getEmployee().getId()); } else user = securityUtils.getCurrentUser(); // For legacy application - create only SewarageIndex if (sewerageApplicationDetails.getConnection().getLegacy() && (null == sewerageApplicationDetails.getId() || null != sewerageApplicationDetails.getId() && sewerageApplicationDetails.getStatus().getCode() .equalsIgnoreCase(APPLICATION_STATUS_SANCTIONED))) { sewerageIndexService.createSewarageIndex(sewerageApplicationDetails, assessmentDetails); return; } ApplicationIndex applicationIndex = applicationIndexService .findByApplicationNumber(sewerageApplicationDetails.getApplicationNumber()); // update existing application index if (applicationIndex != null && null != sewerageApplicationDetails.getId()) { applicationIndex.setStatus(sewerageApplicationDetails.getStatus().getDescription()); applicationIndex.setOwnerName(user != null ? user.getUsername() + "::" + user.getName() : ""); // mark application index as closed on Connection Sanction if (sewerageApplicationDetails.getStatus().getCode().equals(APPLICATION_STATUS_SANCTIONED)) { applicationIndex.setApproved(ApprovalStatus.APPROVED); applicationIndex.setClosed(ClosureStatus.YES); } // mark application index as rejected and closed on Connection // cancellation else if (sewerageApplicationDetails.getStatus().getCode().equals(APPLICATION_STATUS_CANCELLED)) { applicationIndex.setApproved(ApprovalStatus.REJECTED); applicationIndex.setClosed(ClosureStatus.YES); } if (sewerageApplicationDetails.getConnection().getShscNumber() != null) applicationIndex.setConsumerCode(sewerageApplicationDetails.getConnection().getShscNumber()); applicationIndexService.updateApplicationIndex(applicationIndex); sewerageIndexService.createSewarageIndex(sewerageApplicationDetails, assessmentDetails); } else { // Create New ApplicationIndex on create sewerage connection if (sewerageApplicationDetails.getApplicationDate() == null) sewerageApplicationDetails.setApplicationDate(new Date()); if (LOG.isDebugEnabled()) LOG.debug("Application Index creation Started... "); AppConfigValues slaForSewerageConn = null; if (sewerageApplicationDetails != null && sewerageApplicationDetails.getApplicationType() != null && SewerageTaxConstants.APPLICATION_TYPE_NAME_NEWCONNECTION .equals(sewerageApplicationDetails.getApplicationType().getName())) { slaForSewerageConn = getSlaAppConfigValuesForMarriageReg(SewerageTaxConstants.MODULE_NAME, SewerageTaxConstants.SLAFORNEWSEWERAGECONNECTION); } else if (sewerageApplicationDetails != null && sewerageApplicationDetails.getApplicationType() != null && SewerageTaxConstants.APPLICATION_TYPE_NAME_CHANGEINCLOSETS .equals(sewerageApplicationDetails.getApplicationType().getName())) { slaForSewerageConn = getSlaAppConfigValuesForMarriageReg(SewerageTaxConstants.MODULE_NAME, SewerageTaxConstants.SLAFORCHANGEINCLOSET); } applicationIndex = ApplicationIndex.builder().withModuleName(APPL_INDEX_MODULE_NAME) .withApplicationNumber(sewerageApplicationDetails.getApplicationNumber()) .withApplicationDate(sewerageApplicationDetails.getApplicationDate()) .withApplicationType(sewerageApplicationDetails.getApplicationType().getName()) .withApplicantName(consumerName.toString()) .withStatus(sewerageApplicationDetails.getStatus().getDescription()) .withUrl(String.format(STMS_APPLICATION_VIEW, sewerageApplicationDetails.getApplicationNumber(), sewerageApplicationDetails.getConnectionDetail().getPropertyIdentifier())) .withApplicantAddress(assessmentDetails.getPropertyAddress()) .withOwnername(user.getUsername() + "::" + user.getName()) .withChannel(sewerageApplicationDetails.getSource() == null ? Source.SYSTEM.toString() : sewerageApplicationDetails.getSource()) .withDisposalDate(sewerageApplicationDetails.getDisposalDate()) .withMobileNumber(mobileNumber.toString()).withClosed(ClosureStatus.NO) .withAadharNumber(aadharNumber.toString()) .withSla(slaForSewerageConn != null && slaForSewerageConn.getValue() != null ? Integer.valueOf(slaForSewerageConn.getValue()) : 0) .withApproved(ApprovalStatus.INPROGRESS).build(); applicationIndexService.createApplicationIndex(applicationIndex); if (LOG.isDebugEnabled()) LOG.debug("Application Index creation completed..."); sewerageIndexService.createSewarageIndex(sewerageApplicationDetails, assessmentDetails); } }
From source file:com.topsec.tsm.sim.report.util.ReportUiUtil.java
/** * /*from www .j av a 2s . c o m*/ * , * * @param String * sTime * * @param String * eTime ? * * @return String * */ public static long countTime(String sTime, String eTime) { long result1 = -1; long result2 = -1; SimpleDateFormat smpFmt1 = new SimpleDateFormat(ReportUiConfig.dFormat1); try { result1 = (new Date().getTime() - smpFmt1.parse(eTime).getTime()) / 1000; result2 = (smpFmt1.parse(eTime).getTime() - smpFmt1.parse(sTime).getTime()) / 1000; } catch (ParseException e) { log.error("Error:" + e.getMessage()); e.printStackTrace(); } if (result2 > result1) return result2; return result1; }
From source file:com.topsec.tsm.sim.report.util.ReportUiUtil.java
/** * /*from www.j a v a 2 s. c o m*/ * , * * @param String * sTime * * @param String * eTime ? * * @return String * */ public static boolean countTime(String sTime, String eTime, String ruleDate) { SimpleDateFormat smpFmt1 = new SimpleDateFormat(ReportUiConfig.dFormat1); boolean reValue = false; try { long result = (smpFmt1.parse(eTime).getTime() - smpFmt1.parse(sTime).getTime()) / 1000; if (ruleDate.equals("hour") && result == 0) return true; if (ruleDate.equals("day") && result == 0) return true; if (ruleDate.equals("month") && result == 0) return true; if (ruleDate.equals("qushi") && result >= 0) return true; if (ruleDate.equals("qs") && result >= 0) return true; } catch (ParseException e) { log.error("Error:" + e.getMessage()); e.printStackTrace(); } return reValue; }
From source file:com.topsec.tsm.sim.report.util.ReportUiUtil.java
/** * //from w w w . java 2 s . c o m * ?[] * * @param String * date * @param String * ruleDate [] * * @return Date * */ public static String getAddDate(String date, String ruleDate, String table) { Calendar reValue = Calendar.getInstance(); SimpleDateFormat smpFmt1 = new SimpleDateFormat(ReportUiConfig.dFormat1); try { reValue.setTime(smpFmt1.parse(date)); } catch (ParseException e) { log.error("Error:" + e.getMessage()); e.printStackTrace(); } //2012-04-19 ?, ??? //?? ?0 if (ruleDate.equals("hour")) { if (table.toLowerCase().indexOf("topflow") >= 0) { reValue.add(Calendar.MINUTE, 5);// 5 } else { reValue.add(Calendar.MINUTE, 10);// 10 } } if (ruleDate.equals("day")) { if (table.toLowerCase().indexOf("monitor") >= 0) { reValue.add(Calendar.HOUR_OF_DAY, 1);// 1? } else if (table.toLowerCase().indexOf("topflow") >= 0) { reValue.add(Calendar.HOUR_OF_DAY, 1);// 1? } else { reValue.add(Calendar.HOUR_OF_DAY, 6);// 6? } } if (ruleDate.equals("month")) reValue.add(Calendar.DAY_OF_YEAR, 1);// 1 return smpFmt1.format(reValue.getTime()); }