List of usage examples for java.text ParseException getLocalizedMessage
public String getLocalizedMessage()
From source file:fr.cs.examples.propagation.DSSTPropagation.java
/** Program entry point. * @param args program arguments/*from w w w .j a v a 2s . c o m*/ */ public static void main(String[] args) { try { // configure Orekit data acces Utils.setDataRoot("tutorial-orekit-data"); // input/output (in user's home directory) File input = new File(new File(System.getProperty("user.home")), "dsst-propagation.in"); File output = new File(input.getParentFile(), "dsst-propagation.out"); new DSSTPropagation().run(input, output); } catch (IOException ioe) { System.err.println(ioe.getLocalizedMessage()); System.exit(1); } catch (IllegalArgumentException iae) { System.err.println(iae.getLocalizedMessage()); System.exit(1); } catch (OrekitException oe) { System.err.println(oe.getLocalizedMessage()); System.exit(1); } catch (ParseException pe) { System.err.println(pe.getLocalizedMessage()); System.exit(1); } }
From source file:fr.cs.examples.bodies.Phasing.java
/** Program entry point. * @param args program arguments//from ww w .java2 s . com */ public static void main(String[] args) { try { if (args.length != 1) { System.err.println("usage: java fr.cs.examples.bodies.Phasing filename"); System.exit(1); } // configure Orekit Autoconfiguration.configureOrekit(); // input/out URL url = Phasing.class.getResource("/" + args[0]); if (url == null) { System.err.println(args[0] + " not found"); System.exit(1); } File input = new File(url.toURI().getPath()); new Phasing().run(input); } catch (URISyntaxException use) { System.err.println(use.getLocalizedMessage()); System.exit(1); } catch (IOException ioe) { System.err.println(ioe.getLocalizedMessage()); System.exit(1); } catch (IllegalArgumentException iae) { iae.printStackTrace(System.err); System.err.println(iae.getLocalizedMessage()); System.exit(1); } catch (ParseException pe) { System.err.println(pe.getLocalizedMessage()); System.exit(1); } catch (OrekitException oe) { oe.printStackTrace(System.err); System.err.println(oe.getLocalizedMessage()); System.exit(1); } }
From source file:Main.java
public static long ISOtoEpoch(String time) { try {// w w w . j a v a 2s.co m Date d = ISO8601DATEFORMAT.parse(time); return d.getTime(); } catch (ParseException e) { Log.e("Error", e.getLocalizedMessage()); return -2; } }
From source file:org.dd4t.databind.util.JsonUtils.java
public static TCMURI getTcmUriFromField(String fieldName, JsonNode node) { if (!node.has(fieldName)) { return null; }// w w w . ja va2 s . c o m String tcmUri = node.get(fieldName).textValue(); TCMURI uri = null; try { uri = new TCMURI(tcmUri); } catch (ParseException e) { LOG.error(e.getLocalizedMessage(), e); } return uri; }
From source file:org.apache.wiki.util.HttpUtil.java
/** * If returns true, then should return a 304 (HTTP_NOT_MODIFIED) * @param req the HTTP request/*from w ww .j a v a 2s .c om*/ * @param pageName the wiki page name to check for * @param lastModified the last modified date of the wiki page to check for * @return the result of the check */ public static boolean checkFor304(HttpServletRequest req, String pageName, Date lastModified) { // // We'll do some handling for CONDITIONAL GET (and return a 304) // If the client has set the following headers, do not try for a 304. // // pragma: no-cache // cache-control: no-cache // if ("no-cache".equalsIgnoreCase(req.getHeader("Pragma")) || "no-cache".equalsIgnoreCase(req.getHeader("cache-control"))) { // Wants specifically a fresh copy } else { // // HTTP 1.1 ETags go first // String thisTag = createETag(pageName, lastModified); String eTag = req.getHeader("If-None-Match"); if (eTag != null && eTag.equals(thisTag)) { return true; } // // Next, try if-modified-since // DateFormat rfcDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); try { long ifModifiedSince = req.getDateHeader("If-Modified-Since"); //log.info("ifModifiedSince:"+ifModifiedSince); if (ifModifiedSince != -1) { long lastModifiedTime = lastModified.getTime(); //log.info("lastModifiedTime:" + lastModifiedTime); if (lastModifiedTime <= ifModifiedSince) { return true; } } else { try { String s = req.getHeader("If-Modified-Since"); if (s != null) { Date ifModifiedSinceDate = rfcDateFormat.parse(s); //log.info("ifModifiedSinceDate:" + ifModifiedSinceDate); if (lastModified.before(ifModifiedSinceDate)) { return true; } } } catch (ParseException e) { log.warn(e.getLocalizedMessage(), e); } } } catch (IllegalArgumentException e) { // Illegal date/time header format. // We fail quietly, and return false. // FIXME: Should really move to ETags. } } return false; }
From source file:org.openmrs.module.basicexample.web.controller.BasicExampleManageController.java
@RequestMapping(value = "/module/patientlist/register.form", method = RequestMethod.GET) public String registrationform(HttpSession httpSession, @RequestParam(value = "patient_first_name", required = false) String first_name, @RequestParam(value = "patient_middle_name", required = false) String middle_name, @RequestParam(value = "patient_family_name", required = false) String family_name, @RequestParam(value = "patient_openMRSId", required = false) String openMRSId, @RequestParam(value = "patient_address", required = false) String address, @RequestParam(value = "patient_dob", required = false) String dob, @RequestParam(value = "patient_gender", required = false) String gender) { int id = Integer.parseInt(openMRSId);//converting to int String expectedPattern = "dd/MM/yyyy"; SimpleDateFormat formatter = new SimpleDateFormat(expectedPattern); try {/* w w w. ja v a 2 s. c o m*/ // give the formatter a String that matches the SimpleDateFormat pattern Date date = formatter.parse(dob); Patient patient = new Patient(); PersonName personName = new PersonName(); PersonAddress personAddress = new PersonAddress(); PatientIdentifier patientIdentifier = new PatientIdentifier(); PatientIdentifierType patientIdentifierType = Context.getPatientService() .getPatientIdentifierTypeByUuid("8d79403a-c2cc-11de-8d13-0010c6dffd0f"); patientIdentifier.setDateCreated(new Date()); patientIdentifier.setIdentifierType(patientIdentifierType); patientIdentifier.setLocation(Context.getLocationService().getDefaultLocation()); patientIdentifier.setIdentifier(String.valueOf(id)); patientIdentifier.setPreferred(true); /*patientIdentifier.setPatientIdentifierId(id);*/ personName.setGivenName(first_name); personName.setMiddleName(middle_name); personName.setFamilyName(family_name); personAddress.setAddress1(address); patient.addAddress(personAddress); patient.addName(personName); patient.setBirthdate(date); patient.addIdentifier(patientIdentifier); patient.setGender(gender); Context.getPatientService().savePatient(patient); httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Registered Successfully"); return "redirect:manage.jsp"; } catch (ParseException ex) { httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, ex.getLocalizedMessage()); return "redirect:manage.form"; } }
From source file:net.osten.watermap.convert.SanMateoWildernessReport.java
private WaterReport parseDataLine(String line) { WaterReport result = new WaterReport(); // Example line: // name, description, state, last report, reported by, lat, lon. // Pigeon Springs, trough had nasty water, LOW,2/27/16, darren@osten.net, 1, 2 try {//from ww w . j a va2s . com String[] fields = line.split(","); result.setName(fields[0]); result.setDescription(fields[1]); result.setLocation(result.getName()); result.setState(mapWaterState(fields[2])); result.setLastReport(dateFormatter.parse(fields[3].trim())); result.setSource(fields[4]); result.setLat(new BigDecimal(fields[5].trim())); result.setLon(new BigDecimal(fields[6].trim())); } catch (ParseException e) { log.warning(e.getLocalizedMessage()); } return result; }
From source file:jp.dip.komusubi.botter.gae.module.jal5971.FlightStatusEntry.java
public Date getArrivalDate() { Date date = null;//from w w w . ja v a2 s. com try { if (getElement(column, 7) != null) date = DateUtils.parseDate(getElement(column, 7).getText().trim(), new String[] { HOUR_FORMAT }); } catch (ParseException e) { logger.warn("arrivalDate() parse error {}", e.getLocalizedMessage()); } return date; }
From source file:jp.dip.komusubi.botter.gae.module.jal5971.FlightStatusEntry.java
public Date getDepartureDate() { Date date = null;/* ww w.j a va2 s . c o m*/ try { if (getElement(column, 3) != null) date = DateUtils.parseDate(getElement(column, 3).getText().trim(), new String[] { HOUR_FORMAT }); } catch (ParseException e) { logger.warn("departureDate() parse error {}", e.getLocalizedMessage()); } return date; }
From source file:net.xisberto.work_schedule.database.Database.java
private Calendar parseCalendar(String string) { Calendar cal = Calendar.getInstance(); try {//from w w w.j a v a2 s . c o m cal.setTime(dateTimeFormat.parse(string)); } catch (ParseException e) { log(e.getLocalizedMessage()); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); } return cal; }