List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:fi.vm.sade.organisaatio.api.DateParam.java
@Override protected Date parse(String param) throws Throwable { if (StringUtils.isEmpty(param)) { return null; }/*from www .j a v a 2 s .c o m*/ final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { return dateFormat.parse(param); } catch (ParseException e) { throw new WebApplicationException(Response.status(Status.BAD_REQUEST) .entity("Couldn't parse date string: " + e.getMessage()).build()); } }
From source file:com.github.dbourdette.otto.source.schedule.SourceScheduleWatcher.java
public boolean isEligible(String cronExpression, DateTime dateTime) { if (StringUtils.isEmpty(cronExpression)) { return false; }//from ww w . jav a2 s. com Calendar calendar = Calendar.getInstance(); calendar.setTime(dateTime.toDate()); try { return CronTabExpression.parse(cronExpression).matches(calendar); } catch (ParseException e) { logs.error("Failed to see if schedule is eligible for running, reason : " + e.getMessage(), e); return false; } }
From source file:com.thingtrack.konekti.view.web.workbench.MattrackServlet.java
@Override public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (counterService == null) return;/*from w ww. j a v a 2 s. c o m*/ response.setContentType("text/plain"); // STEP01: parse count servlet payload //localhost:8080/mattrack?dispositivo=D2&numeroConteos=3&pisada1=1-1372000554&pisada2=0-1372000554&pisada3=1-1372000554 int numberOfCounts = Integer.parseInt(request.getParameter("numeroConteos")); String deviceName = request.getParameter("dispositivo"); List<Counter> counts = new ArrayList<Counter>(); try { String pisada[] = new String[numberOfCounts]; String delimiter = "-"; // parse data for (int i = 0; i < numberOfCounts; i++) { pisada[i] = request.getParameter("pisada" + Integer.toString(i + 1)); String[] parsed = pisada[i].split(delimiter); counts.add(createCount(deviceName, parsed[0], parsed[1])); } } catch (ParseException e) { response.getWriter().write(e.getMessage()); return; } // save count in DB try { for (int i = 0; i < numberOfCounts; i++) counterService.save(counts.get(i)); } catch (Exception e) { response.getWriter().write(e.getMessage()); return; } // send sensor event data for the last message eventSensorService.sendData(counts.get(numberOfCounts - 1)); // show message response.getWriter().write("Count: [DEVICE]=" + (counts.get(0)).getDeviceName() + "; [WAY]=" + (counts.get(0)).getWay() + "; [DATE]=" + (counts.get(0)).getCountDate() + " saved correctly!"); }
From source file:org.javelin.sws.ext.bind.internal.model.SimpleTypePattern.java
@Override public T consumeValue(XMLEventReader eventReader, UnmarshallingContext context) throws XMLStreamException { String value = this.consumeNonNullString(eventReader, context); if (this.formatter == null) { @SuppressWarnings("unchecked") T v = (T) value;//from w w w. j a va 2s . com return v; } try { return this.formatter.parse(value, Locale.getDefault()); } catch (ParseException e) { throw new XMLStreamException(e.getMessage(), e); } }
From source file:com.jason.sms.util.CustomSqlDateEditor.java
/** * Parse the Date from the given text, using the specified DateFormat. *///from ww w. j a v a 2 s.c o m @Override public void setAsText(String text) throws IllegalArgumentException { if (this.allowEmpty && !StringUtils.hasText(text)) { // Treat empty String as null value. setValue(null); } else if (text != null && this.exactDateLength >= 0 && text.length() != this.exactDateLength) { throw new IllegalArgumentException( "Could not parse date: it is not exactly" + this.exactDateLength + "characters long"); } else { try { java.util.Date date = this.dateFormat.parse(text); java.sql.Date sqlDate = new java.sql.Date(date.getTime()); setValue(sqlDate); } catch (ParseException ex) { throw new IllegalArgumentException("Could not parse date: " + ex.getMessage(), ex); } } }
From source file:com.arcao.menza.fragment.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); Preference feedBackPref = findPreference("feedback"); feedBackPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override/*from w w w .ja va2 s . co m*/ public boolean onPreferenceClick(Preference preference) { FeedbackHelper.sendFeedBack(getActivity(), R.string.feedback_email, R.string.feedback_subject, R.string.feedback_message); return true; } }); Preference licensesPref = findPreference("licenses"); licensesPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent i = new Intent(getActivity(), WebViewActivity.class); i.putExtra(WebViewActivity.PARAM_TITLE, R.string.pref_licenses); i.putExtra(WebViewActivity.PARAM_RAW_RESOURCE, R.raw.licenses); startActivity(i); return true; } }); findPreference("version").setSummary(getVersion(getActivity()) + " (" + BuildConfig.GIT_SHA + ")"); try { findPreference("build_time").setSummary(DateFormat .getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, getResources().getConfiguration().locale) .format(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parse(BuildConfig.BUILD_TIME))); } catch (ParseException e) { Log.e(TAG, e.getMessage(), e); } // fix for Android 2.x updateListPreferenceSummary(PrefConstant.PRICE_GROUP); updateListPreferenceSummary(PrefConstant.DEFAULT_PLACE); }
From source file:com.hg.ecommerce.action.extension.editor.CustomDateEditor.java
/** * Parse the Date from the given text, using the specified DateFormat. *///from ww w. j a v a 2s . co m @Override public void setAsText(String text) throws IllegalArgumentException { if (this.allowEmpty && !StringUtils.hasText(text)) { // Treat empty String as null value. setValue(null); } else if (text != null && this.exactDateLength >= 0 && text.length() != this.exactDateLength) { throw new IllegalArgumentException( "Could not parse date: it is not exactly" + this.exactDateLength + "characters long"); } else { try { setValue(this.dateFormat.parse(text)); } catch (ParseException ex) { throw new IllegalArgumentException("Could not parse date: " + ex.getMessage(), ex); } } }
From source file:org.jenkins_ci.update_center.model.MavenArtifact.java
public Date getTimestampAsDate() throws IOException { long lastModified = getTimestamp(); SimpleDateFormat bdf = getDateFormat(); Date tsDate;//from w w w .j av a2 s .c o m try { tsDate = bdf.parse(bdf.format(new Date(lastModified))); } catch (ParseException pe) { throw new IOException(pe.getMessage()); } return tsDate; }
From source file:hudson.logging.LogRecorderManager.java
/** * Creates a new log recorder.// w w w .j a va 2 s . co m */ public HttpResponse doNewLogRecorder(@QueryParameter String name) { try { Hudson.checkGoodName(name); } catch (ParseException e) { throw new Failure(e.getMessage()); } logRecorders.put(name, new LogRecorder(name)); // redirect to the config screen return new HttpRedirect(name + "/configure"); }
From source file:org.egov.ptis.domain.entity.property.DailyCollectionReportSearchVLT.java
public void setFromDate(final String fromDate) { if (isNotBlank(fromDate)) try {/*from w ww .jav a 2s. c om*/ this.fromDate = ft.format(dtft.parse(fromDate)); } catch (final ParseException e) { throw new ValidationException(e.getMessage()); } }