List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:monasca.common.middleware.HttpAuthClient.java
private boolean isExpired(String expires) { Date tokenExpiryDate;//from w w w . ja va 2 s . co m if (expiryFormat.get() == null) { expiryFormat.set(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")); expiryFormat.get().setTimeZone(TimeZone.getTimeZone("UTC")); } try { // The date looks like: 2014-11-13T02:34:59.953729Z // SimpleDateFormat can't handle the microseconds so take them off final String tmp = expires.replaceAll("\\.[\\d]+Z", "Z"); tokenExpiryDate = expiryFormat.get().parse(tmp); } catch (ParseException e) { logger.warn("Failure parsing Admin Token expiration date: {}", e.getMessage()); return true; } Date current = new Date(); return tokenExpiryDate.getTime() < (current.getTime() + DELTA_TIME_IN_SEC * 1000); }
From source file:org.kuali.kfs.module.endow.web.struts.TransactionSummaryAction.java
/** * Generates Transaction Statement in the PDF form * // ww w .j a v a2s .c o m * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ public ActionForward print(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { TransactionSummaryReportService transactionSummaryReportService = SpringContext .getBean(TransactionSummaryReportService.class); // get all the value strings from the form TransactionSummaryForm transactionSummaryForm = (TransactionSummaryForm) form; String kemids = transactionSummaryForm.getKemid(); String benefittingOrganziationCampuses = transactionSummaryForm.getBenefittingOrganziationCampus(); String benefittingOrganziationCharts = transactionSummaryForm.getBenefittingOrganziationChart(); String benefittingOrganziations = transactionSummaryForm.getBenefittingOrganziation(); String typeCodes = transactionSummaryForm.getTypeCode(); String purposeCodes = transactionSummaryForm.getPurposeCode(); String combineGroupCodes = transactionSummaryForm.getCombineGroupCode(); String beginningDate = transactionSummaryForm.getBeginningDate(); String endingDate = transactionSummaryForm.getEndingDate(); String endowmentOption = transactionSummaryForm.getEndowmentOption(); String reportOption = transactionSummaryForm.getReportOption(); String listKemidsOnHeader = transactionSummaryForm.getListKemidsInHeader(); String summaryTotalsOnly = transactionSummaryForm.getSummaryTotalsOnly(); String closedIndicator = transactionSummaryForm.getClosedIndicator(); String message = transactionSummaryForm.getMessage(); // check to see if the ending date is greater than the beginning date SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy"); try { java.util.Date beginDate = df.parse(beginningDate); java.util.Date endDate = df.parse(endingDate); if (beginDate.compareTo(endDate) >= 0) { transactionSummaryForm.setMessage(ERROR_REPORT_ENDING_DATE_NOT_GREATER_THAN_BEGINNING_DATE); return mapping.findForward(KFSConstants.MAPPING_BASIC); } } catch (ParseException e) { transactionSummaryForm.setMessage(e.getMessage()); return mapping.findForward(KFSConstants.MAPPING_BASIC); } List<TransactionSummaryReportDataHolder> transactionSummaryReportList = null; /* * Creates the report data based on the selected criteria. * The criteria are selected as follows. * 1. Kemid and the other criteria cannot be selected at the same time. * 2. If none of them are selected, all kemids will be selected. * 3. The other criteria other than kemid are "OR" combined. * 4. All the criteria in the text input can be multiple by the use of wild card or the separator ('&' for kemid, ',' for the others) * 5. Beginning Date and Ending Date are required. */ if (StringUtils.isNotBlank(beginningDate) && StringUtils.isNotBlank(endingDate)) { if (StringUtils.isNotBlank(kemids)) { if ((StringUtils.isNotBlank(benefittingOrganziationCampuses) || StringUtils.isNotBlank(benefittingOrganziationCharts) || StringUtils.isNotBlank(benefittingOrganziations) || StringUtils.isNotBlank(typeCodes) || StringUtils.isNotBlank(purposeCodes) || StringUtils.isNotBlank(combineGroupCodes))) { // kemid and the other criteria cannot be selected at the same time transactionSummaryForm.setMessage(ERROR_REPORT_KEMID_WITH_OTHER_CRITERIA); return mapping.findForward(KFSConstants.MAPPING_BASIC); } else { // by kemid only List<String> kemidList = parseValueString(kemids, KEMID_SEPERATOR); transactionSummaryReportList = transactionSummaryReportService .getTransactionSummaryReportsByKemidByIds(kemidList, beginningDate, endingDate, endowmentOption, closedIndicator, reportOption); } } else { if ((StringUtils.isBlank(benefittingOrganziationCampuses) && StringUtils.isBlank(benefittingOrganziationCharts) && StringUtils.isBlank(benefittingOrganziations) && StringUtils.isBlank(typeCodes) && StringUtils.isBlank(purposeCodes) && StringUtils.isBlank(combineGroupCodes))) { // for all kemids transactionSummaryReportList = transactionSummaryReportService .getTransactionSummaryReportForAllKemids(beginningDate, endingDate, endowmentOption, closedIndicator, reportOption); } else { // by other criteria transactionSummaryReportList = transactionSummaryReportService .getTransactionSummaryReportsByOtherCriteria( parseValueString(benefittingOrganziationCampuses, OTHER_CRITERIA_SEPERATOR), parseValueString(benefittingOrganziationCharts, OTHER_CRITERIA_SEPERATOR), parseValueString(benefittingOrganziations, OTHER_CRITERIA_SEPERATOR), parseValueString(typeCodes, OTHER_CRITERIA_SEPERATOR), parseValueString(purposeCodes, OTHER_CRITERIA_SEPERATOR), parseValueString(combineGroupCodes, OTHER_CRITERIA_SEPERATOR), beginningDate, endingDate, endowmentOption, closedIndicator, reportOption); } } } else { transactionSummaryForm.setMessage(ERROR_BOTH_BEGINNING_AND_ENDING_DATE_REQUIRED); return mapping.findForward(KFSConstants.MAPPING_BASIC); } // see if you have something to print if (transactionSummaryReportList != null && !transactionSummaryReportList.isEmpty()) { // prepare the header sheet data EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder = transactionSummaryReportService .createReportHeaderSheetData(getKemidsSelected(transactionSummaryReportList), parseValueString(benefittingOrganziationCampuses, OTHER_CRITERIA_SEPERATOR), parseValueString(benefittingOrganziationCharts, OTHER_CRITERIA_SEPERATOR), parseValueString(benefittingOrganziations, OTHER_CRITERIA_SEPERATOR), parseValueString(typeCodes, OTHER_CRITERIA_SEPERATOR), parseValueString(purposeCodes, OTHER_CRITERIA_SEPERATOR), parseValueString(combineGroupCodes, OTHER_CRITERIA_SEPERATOR), REPORT_NAME, endowmentOption, null); // generate the report in PDF ByteArrayOutputStream pdfStream = new TransactionSummaryReportPrint().printTransactionSummaryReport( reportRequestHeaderDataHolder, transactionSummaryReportList, listKemidsOnHeader, reportOption, summaryTotalsOnly); if (pdfStream != null) { transactionSummaryForm.setMessage("Reports Generated"); WebUtils.saveMimeOutputStreamAsFile(response, "application/pdf", pdfStream, REPORT_FILE_NAME); return null; } } // No report was generated transactionSummaryForm.setMessage("Report was not generated for " + kemids + "."); return mapping.findForward(KFSConstants.MAPPING_BASIC); }
From source file:net.orpiske.ssps.common.resource.HttpResourceExchange.java
/** * Gets the last modified value from the header * @param response the HTTP response//from ww w . ja va 2 s. c o m * @return The content length */ private long getLastModified(HttpResponse response) { Header header = response.getFirstHeader(HttpHeaders.LAST_MODIFIED); String tmp = header.getValue(); //Tue, 26 Jun 2012 02:25:57 GMT SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z"); Date date; try { date = dateFormat.parse(tmp); } catch (ParseException e) { logger.warn("The last modified date provided by the server is invalid"); if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } return 0; } return date.getTime(); }
From source file:fr.paris.lutece.plugins.calendar.service.search.CalendarLuceneSearchEngine.java
/** * Convert the SearchItem list on SearchResult list * @param listSource The source list// w w w .ja va 2 s. c om * @return The result list */ private List<CalendarSearchResult> convertList(List<CalendarSearchItem> listSource) { List<CalendarSearchResult> listDest = new ArrayList<CalendarSearchResult>(); for (CalendarSearchItem item : listSource) { CalendarSearchResult result = new CalendarSearchResult(); result.setId(item.getId()); try { result.setDate(DateTools.stringToDate(item.getDate())); } catch (ParseException e) { AppLogService .error("Bad Date Format for indexed item \"" + item.getTitle() + "\" : " + e.getMessage()); } result.setUrl(item.getUrl()); result.setTitle(item.getTitle()); result.setSummary(item.getSummary()); result.setType(item.getType()); result.setHtmlSummary(item.getHtmlSummary()); listDest.add(result); } return listDest; }
From source file:com.mycompany.listBoxer.panel.ListBoxerForm.java
private void AlphabeticCheckBoxActionPerformed(ActionEvent evt) { try {// ww w. jav a2s. com jTextField1.setValue(StringUtils.EMPTY); factory.setDefaultFormatter((new MaskFormatter("????"))); jTextField1.setFormatterFactory(factory); } catch (ParseException e) { e.getMessage(); } RangeComboBox.setModel(new DefaultComboBoxModel<String>( new String[] { RangeType.ALL.getKey(), RangeType.AM.getKey(), RangeType.NZ.getKey() })); }
From source file:org.apache.nutch.tools.AbstractCommonCrawlFormat.java
protected String getTimestamp() { if (this.simpleDateFormat) { String timestamp = null;/* w w w . j av a2s .co m*/ try { long epoch = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z") .parse(ifNullString(metadata.get(Metadata.LAST_MODIFIED))).getTime(); timestamp = String.valueOf(epoch); } catch (ParseException pe) { LOG.warn(pe.getMessage()); } return timestamp; } else { return ifNullString(metadata.get(Metadata.LAST_MODIFIED)); } }
From source file:org.apache.nutch.tools.AbstractCommonCrawlFormat.java
protected String getResponseDate() { if (this.simpleDateFormat) { String timestamp = null;//from w w w . j av a 2 s . c o m try { long epoch = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z") .parse(ifNullString(metadata.get("Date"))).getTime(); timestamp = String.valueOf(epoch); } catch (ParseException pe) { LOG.warn(pe.getMessage()); } return timestamp; } else { return ifNullString(metadata.get("Date")); } }
From source file:org.apache.nutch.tools.AbstractCommonCrawlFormat.java
protected String getImported() { if (this.simpleDateFormat) { String timestamp = null;//from w w w . j a v a 2 s . c om try { long epoch = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z") .parse(ifNullString(metadata.get("Date"))).getTime(); timestamp = String.valueOf(epoch); } catch (ParseException pe) { LOG.warn(pe.getMessage()); } return timestamp; } else { return ifNullString(metadata.get("Date")); } }
From source file:com.mycompany.listBoxer.panel.ListBoxerForm.java
private void NumericCheckBoxActionPerformed(ActionEvent evt) { try {/*from w w w.jav a 2 s .com*/ jTextField1.setValue(StringUtils.EMPTY); factory.setDefaultFormatter(new MaskFormatter("####")); jTextField1.setFormatterFactory(factory); } catch (ParseException e) { e.getMessage(); } RangeComboBox.setModel( new DefaultComboBoxModel<String>(new String[] { RangeType.ALL.getKey(), RangeType.NUM1.getKey(), RangeType.NUM2.getKey(), RangeType.NUM3.getKey(), RangeType.NUM4.getKey() })); }
From source file:com.mycompany.listBoxer.panel.ListBoxerForm.java
private void CombinedCheckBoxActionPerformed(ActionEvent evt) { try {/*w w w . ja v a 2 s. c o m*/ jTextField1.setValue(StringUtils.EMPTY); factory.setDefaultFormatter(new MaskFormatter("****")); jTextField1.setFormatterFactory(factory); } catch (ParseException e) { e.getMessage(); } RangeComboBox.setModel(new DefaultComboBoxModel<String>(new String[] { RangeType.ALL.getKey(), RangeType.AM.getKey(), RangeType.NZ.getKey(), RangeType.NUM1.getKey(), RangeType.NUM2.getKey(), RangeType.NUM3.getKey(), RangeType.NUM4.getKey() })); }