List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:com.opendesign.utils.Day.java
public static Date getDateWithTyphoonFormatString(String timestamp) { SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = null;/*from ww w. j av a2 s .c o m*/ try { date = formatter.parse(timestamp); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:com.opendesign.utils.Day.java
public static Date getDateWithFormatString(String timestamp, String format) { SimpleDateFormat formatter = new SimpleDateFormat(format); Date date = null;/*from ww w.j a v a 2s . co m*/ try { date = formatter.parse(timestamp); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:com.opendesign.utils.Day.java
public static Date getCurrentDateWithFormatString(String format) { SimpleDateFormat formatter = new SimpleDateFormat(format); Date date = null;// ww w . j a v a2 s. co m try { date = formatter.parse(Day.toStringAsyyyyMMddHHmmss(System.currentTimeMillis())); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:com.opendesign.utils.Day.java
public static Date toDate(String timestamp) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); Date date = null;/*from w w w .ja v a 2s . c o m*/ try { date = sdf.parse(timestamp); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:com.opendesign.utils.Day.java
public static Date toDate(String timestamp, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); Date date = null;/*from ww w . j a va2 s .com*/ try { date = sdf.parse(timestamp); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:com.opendesign.utils.Day.java
public static Date getDate(long time) { // if(time==0) // time = 20000101000000L; if (time == 0 || String.valueOf(time).length() < 14) time = getCurrentTime();/*from ww w . j a va2s . co m*/ try { return getFormatter().parse(String.valueOf(time)); } catch (ParseException e) { e.printStackTrace(); } return new Date(); }
From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java
public static boolean setCourseName(final String personGroupIdToAdd, String code, String lectureName, String courseName, Context context) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Course"); query.whereEqualTo("Code", code); query.whereNotEqualTo("CourseId", personGroupIdToAdd); try {/*ww w. j a v a2 s.co m*/ if (query.count() != 0) return false; query = ParseQuery.getQuery("Course"); query.whereEqualTo("CourseId", personGroupIdToAdd); if (query.count() == 0) { ParseObject groupName = new ParseObject("Course"); groupName.put("CourseName", courseName); groupName.put("Code", code); groupName.put("CourseId", personGroupIdToAdd); groupName.put("lectureName", ParseUser.getCurrentUser().get("username")); groupName.put("studentList", "{}"); groupName.saveInBackground(); return true; } else { ParseObject courseResult = ((ParseObject) query.getFirst()); courseResult.put("CourseName", courseName); courseResult.put("Code", code); } } catch (com.parse.ParseException e) { e.printStackTrace(); return false; } return true; }
From source file:com.opendesign.utils.Day.java
public static String convertFormattedString(String timestamp, String oldFormat, String format) { if (StringUtils.isEmpty(timestamp)) { return ""; }//from ww w .ja va 2 s . c om SimpleDateFormat formatter = new SimpleDateFormat(oldFormat); SimpleDateFormat formatter2 = new SimpleDateFormat(format); Date date = null; try { date = formatter.parse(timestamp); } catch (ParseException e) { e.printStackTrace(); } return formatter2.format(date); }
From source file:org.openiot.gsn.utils.GSNMonitor.java
public static void parseXML(String s) { try {//from w w w .j ava 2s . com DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); InputSource inputSource = new InputSource(); inputSource.setCharacterStream(new StringReader(s)); Document document = documentBuilder.parse(inputSource); NodeList nodes = document.getElementsByTagName("virtual-sensor"); for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.item(i); String sensor_name = element.getAttribute("name"); if (!sensorsUpdateDelay.containsKey(sensor_name)) continue; // skip sensors that are not monitored logger.warn("Sensor: " + sensor_name); NodeList listOfField = element.getElementsByTagName("field"); for (int j = 0; j < listOfField.getLength(); j++) { Element line = (Element) listOfField.item(j); if (line.getAttribute("name").indexOf("timed") >= 0) { String last_updated_as_string = line.getTextContent(); try { Long last_updated_as_Long = GregorianCalendar.getInstance().getTimeInMillis() - VSensorMonitorConfig.datetime2timestamp(last_updated_as_string); logger.warn(new StringBuilder(last_updated_as_string).append(" => ") .append(VSensorMonitorConfig.ms2dhms(last_updated_as_Long)).toString()); sensorsUpdateDelay.put(sensor_name, last_updated_as_Long); } catch (ParseException e) { errorsBuffer.append("Last update time for sensor ").append(sensor_name) .append(" cannot be read. Error while parsing > ") .append(last_updated_as_string).append(" <\n"); } } } } } catch (Exception e) { logger.warn("Exception while parsing XML\n"); e.printStackTrace(); } }
From source file:controllers.Send.java
public static Result confirmBillPayment() { Form<models.forms.CashInForm> transactionForm = form(models.forms.CashInForm.class) .bindFromRequest(request()); String err = null;/*from w w w. j a v a 2 s . c o m*/ if (transactionForm.hasErrors()) { Logger.debug("Transaction form errors: " + transactionForm.errorsAsJson()); return ok(confirm.render("Transaction information is invalid", null)); } String tokenRequest = transactionForm.get().trackingId; String token = SessionHelper.getToken(); Logger.debug("Request param token : " + tokenRequest + " >< " + token); SessionHelper.removeToken(); if (!token.equals(tokenRequest)) { Logger.debug("Invalid Token Request, route to send form!!!"); return redirect(routes.Send.createBillPayment()); } transactionForm.get().inquiry = new TransactionInquiry(); transactionForm.get().inquiry.idToken = transactionForm.data().get("idToken") != null ? transactionForm.data().get("idToken") : ""; models.User user = SessionHelper.getUser(); transactionForm.get().supervisor = user.supervisor; if ((transactionForm.get().sender.idToken != null) && (!transactionForm.get().sender.idToken.isEmpty())) { models.Customer sender = models.Customer.findByToken(transactionForm.get().sender.idToken); if (sender.getStatistic(1).hasExceedSendLimit(transactionForm.get().senderAmount)) { //flash("error", "Sender customer "+sender.fullName()+" has exceeded its customer limit"); err = "Sender customer " + sender.fullName() + " has exceeded its customer limit"; } } if (SessionHelper.getUser().agentHasExceedSendLimit(transactionForm.get().senderAmount)) { err = "Sender agent has exceeded its credit limit"; } if (transactionForm.get().channel.code.equals("10")) { Corporate corporate = Corporate.find.byId(transactionForm.get().corporate.code); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date birthDate = null; try { birthDate = simpleDateFormat.parse("1980-01-01"); } catch (ParseException e) { e.printStackTrace(); } Customer customerSender = null; Customer customerBeneficiary = null; try { customerSender = Customer.find.where().eq("firstName", corporate.name).eq("lastName", "SENDER") .eq("phoneNumber", corporate.phoneNumber).eq("personalIdType", "OTHER") .eq("personalId", corporate.licenseNumber).eq("birthDate", birthDate).setMaxRows(1) .findUnique(); System.out.println("SENDER : " + Json.toJson(customerSender)); customerBeneficiary = Customer.find.where().eq("firstName", corporate.name) .eq("lastName", "BENEFICIARY").eq("phoneNumber", corporate.phoneNumber) .eq("personalIdType", "OTHER").eq("personalId", corporate.licenseNumber) .eq("birthDate", birthDate).setMaxRows(1).findUnique(); System.out.println("BENEFICIARY : " + Json.toJson(customerBeneficiary)); } catch (Exception e) { } String customerIdSender = customerSender != null ? customerSender.idToken : ""; String customerIdBeneficiary = customerBeneficiary != null ? customerBeneficiary.idToken : ""; System.out.println("SENDER ID : " + customerIdSender); System.out.println("BENEFICIARY ID : " + customerIdBeneficiary); transactionForm.get().sender.idToken = customerIdSender; transactionForm.data().put("sender.firstName", corporate.name); transactionForm.data().put("sender.lastName", "SENDER"); transactionForm.data().put("sender.phoneNumber", corporate.phoneNumber); transactionForm.data().put("sender.country.code", corporate.country.code); transactionForm.data().put("sender.personalIdType", "OTHER"); transactionForm.data().put("sender.personalId", corporate.licenseNumber); transactionForm.data().put("sender.birthDate", "1980-01-01"); transactionForm.get().beneficiary.idToken = customerIdBeneficiary; transactionForm.data().put("beneficiary.firstName", corporate.name); transactionForm.data().put("beneficiary.lastName", "BENEFICIARY"); transactionForm.data().put("beneficiary.phoneNumber", corporate.phoneNumber); transactionForm.data().put("beneficiary.country.code", corporate.country.code); transactionForm.data().put("beneficiary.personalIdType", "OTHER"); transactionForm.data().put("beneficiary.personalId", corporate.licenseNumber); transactionForm.data().put("beneficiary.birthDate", "1980-01-01"); Integer denom = Integer.parseInt(transactionForm.get().billPayment.selectDenom) + 1; transactionForm.data().put("billPayment.selectDenom", denom.toString()); System.out.println("SENDER ID : " + transactionForm.get().sender.idToken); System.out.println("BENEFICIARY ID : " + transactionForm.get().beneficiary.idToken); } return ok(confirm_bill_payment.render(err, transactionForm)); }