Example usage for java.text ParseException printStackTrace

List of usage examples for java.text ParseException printStackTrace

Introduction

In this page you can find the example usage for java.text ParseException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.unilever.audit.services2.Sync_Up.java

private void persistVisit(JSONObject obj) {
    try {//  w w w .j av  a  2s  . c  om
        JSONArray visitsArr = obj.getJSONArray("visits");
        for (int i = 0; i < visitsArr.length(); i++) {

            JSONObject visitObj = (JSONObject) visitsArr.get(i);
            Visit v = new Visit();

            v.setId(visitObj.getString("id"));

            Customers c = em.getReference(Customers.class, new BigDecimal(visitObj.getInt("customerid")));
            v.setCustomerid(c);

            Merchandisers m = em.getReference(Merchandisers.class, new BigDecimal(visitObj.getInt("merchid")));
            v.setMerchandiserid(m);

            try {
                Date date = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy")
                        .parse(visitObj.getString("finishdate"));
                v.setVisitdate(date);
            } catch (java.text.ParseException ex) {
                ex.printStackTrace();
            }

            v.setSubmitteddate(new Date());
            visitFacadeREST.create(v);
        }
    } catch (JSONException ex) {
        ex.printStackTrace();
    }
}

From source file:jp.co.conit.sss.sp.ex1.io.BookListParser.java

@Override
public SPResult<List<Book>> parse(String str) {

    if (str == null) {
        return SPResult.getSystemErrInstance(mContext);
    }/*from   w  w  w. ja  v a2  s . co  m*/

    List<Book> saleBookList = new ArrayList<Book>();
    try {
        JSONObject jsonObject = new JSONObject(str);
        JSONArray productArray = jsonObject.getJSONArray("products");
        int length = productArray.length();
        for (int i = 0; i < length; i++) {

            try {
                JSONObject productObj = productArray.getJSONObject(i);

                String productId = productObj.getString("product_id");
                String title = productObj.getString("title");
                String outline = productObj.getString("outline");

                String publishDateStr = "";
                Date date = null;
                if (productObj.has("publish_date")) {
                    String pub = productObj.getString("publish_date");

                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    try {
                        date = sdf.parse(pub);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }

                    SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
                    publishDateStr = sdf2.format(date);
                }
                // 
                int free = productObj.getInt("is_free");
                boolean isFree = false;
                if (free == 1) {
                    isFree = true;
                } else {
                    isFree = false;
                }

                int dlCount = 0;
                if (productObj.has("summary")) {
                    dlCount = productObj.getInt("summary");
                }

                Book sb = new Book.Builder(productId).title(title).isFree(isFree).publishDateStr(publishDateStr)
                        .outline(outline).dlCount(dlCount).build();
                saleBookList.add(sb);

            } catch (JSONException e) {
                // ?????
            }
        }
    } catch (JSONException e) {
        return SPResult.getSystemErrInstance(mContext);
    }
    return SPResult.getSuccessInstance(saleBookList);
}

From source file:com.ewcms.common.query.mongo.EasyQueryInit.java

private List<LimitLog> findLimitLog(final String id) throws IOException {
    DataOperator<LimitLog> operator = new DataOperator<LimitLog>("limitlog.csv");
    List<LimitLog> logs = operator.loadData(new MapperCallback<LimitLog>() {
        @Override// ww  w . ja  v  a  2 s.  c  o  m
        public LimitLog mapping(String line) {
            String[] array = line.split(",");
            if (!array[1].equals(id)) {
                return null;
            }
            LimitLog log = new LimitLog();
            log.setMoney(Float.valueOf(array[2]).intValue());
            try {
                log.setDate(format.parse(array[3]));
            } catch (ParseException e) {
                e.printStackTrace();
            }
            return log;
        }
    });
    return logs;
}

From source file:org.openmrs.module.urandumodule.web.controller.UranduModuleManageController.java

@RequestMapping(value = "/module/urandumodule/submitForm", method = RequestMethod.GET)
public String submitForm(ModelMap model,
        @RequestParam(value = "family_name", required = false) String family_name,
        @RequestParam(value = "middle_name", required = false) String middle_name,
        @RequestParam(value = "given_name", required = false) String given_name,
        @RequestParam(value = "dob", required = false) String dob,
        @RequestParam(value = "id_number", required = false) String id_number,
        @RequestParam(value = "gender", required = false) String gender,
        @RequestParam(value = "address", required = false) Integer address,
        @RequestParam(value = "postal_code", required = false) Integer postal_code,
        @RequestParam(value = "town", required = false) String town,
        @RequestParam(value = "country", required = false) String country) {

    Person person = new Person();

    PersonName personName = new PersonName();
    personName.setFamilyName(family_name);
    personName.setMiddleName(middle_name);
    personName.setGivenName(given_name);
    //name added to person
    person.addName(personName);/* ww w .  ja  va 2 s .  c  om*/
    PersonAddress personAddress = new PersonAddress();
    personAddress.setAddress1(address.toString());
    personAddress.setCityVillage(town);
    personAddress.setCountry(country);
    personAddress.setPostalCode(postal_code.toString());
    //address added to person
    person.addAddress(personAddress);
    //gender added to person
    person.setGender(gender);

    DateFormat dateFormat = new SimpleDateFormat("dd-mm-yyyy");

    Date birthday = null;
    try {
        birthday = dateFormat.parse(dob);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    person.setBirthdate(birthday);
    /*person.setBirthdate();*/
    Patient patient = new Patient(person);
    PatientService patientService = Context.getPatientService();
    //Identifier issues

    PatientIdentifier openmrsId = new PatientIdentifier();
    String TARGET_ID_KEY = "urandumodule.idType";
    String TARGET_ID = Context.getAdministrationService().getGlobalProperty(TARGET_ID_KEY);
    PatientIdentifierType openmrsIdType = patientService.getPatientIdentifierTypeByName(TARGET_ID);
    openmrsId.setIdentifier(id_number);
    openmrsId.setDateCreated(new Date());
    openmrsId.setLocation(Context.getLocationService().getDefaultLocation());
    openmrsId.setIdentifierType(openmrsIdType);
    PatientIdentifierValidator.validateIdentifier(openmrsId);
    patient.addIdentifier(openmrsId);
    //saving the patient

    if (!patientService.isIdentifierInUseByAnotherPatient(openmrsId)) {
        patientService.savePatient(patient);
        model.addAttribute("save_success", "Patient successfully saved");
        return "redirect:patientForm.form";
    } else {
        model.addAttribute("save_failed", "Patient not saved : duplicate id number");
        return "redirect:patientForm.form";
    }

}

From source file:com.tk.httpClientErp.wsHeadCheck.WsHeadCheckList.java

@SuppressLint("SimpleDateFormat")
private boolean compareTime(String ComTime, String ToTime) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date1 = new Date();
    Date date2 = new Date();
    try {/*w  w  w.  jav a2s. c  o  m*/
        date1 = sdf.parse(ComTime);
        date2 = sdf.parse(ToTime);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date1.before(date2);
}

From source file:com.persistent.cloudninja.controller.RunningInstancesJSONDataController.java

public List<String> generateStartAndEndTime(int year, int month) {
    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.sss");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    Calendar cal = Calendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone("UTC"));

    Date currentDate = cal.getTime();
    int currentMonth = cal.get(Calendar.MONTH) + 1;

    String start = month + "/01/" + year + " 00:00:00.000";
    String end = null;/*from   w w  w  .j  a v a  2  s  .c om*/

    if (month == currentMonth) {
        end = dateFormat.format(currentDate);
    } else {
        try {
            cal.setTime(dateFormat.parse(start));
            int maxDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
            end = month + "/" + maxDay + "/" + year + " 23:59:59.000";

        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
    List<String> time = new ArrayList<String>();
    time.add(start);
    time.add(end);
    return time;
}

From source file:com.itesm.test.servlets.TasksServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String[] description = request.getParameterValues("description");
    String[] priority = request.getParameterValues("priority");
    String[] task_time = request.getParameterValues("task_time");
    String[] end_time = request.getParameterValues("end_time");
    PersonaVO personavo = (PersonaVO) request.getSession().getAttribute("persona");
    TaskManager taskManager = new TaskManager();
    for (int i = 0; i < priority.length; i++) {
        TaskVO wh = new TaskVO();
        SimpleDateFormat sdf = new SimpleDateFormat("hh:mm");
        SimpleDateFormat sdfTimeStamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
        Date durationDate = null;
        Date end_date = null;/*from   w  w  w  .  ja  v a2 s . c  om*/
        try {
            durationDate = sdf.parse(task_time[i]);
            end_date = sdfTimeStamp.parse(end_time[i]);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        wh.setDuration(new Time(durationDate.getTime()));
        wh.setEnd_date(new Timestamp(end_date.getTime()));
        wh.setDescription(description[i]);
        wh.setPriority(Integer.parseInt(priority[i]));
        wh.setAgenda_id(personavo.getAgenda_id());
        System.out.println(wh.toString());
        taskManager.agregar(wh);
    }
    CreateSchedule createSchedule = new CreateSchedule(personavo);
    createSchedule.createSchedule();
    TaskDAO taskDAO = new TaskDAO();
    List<TaskVO> task_list = taskDAO.findByAgenda(personavo.getAgenda_id());
    ListIterator listIterator = task_list.listIterator();
    while (listIterator.hasNext()) {
        TaskVO task = (TaskVO) listIterator.next();
        if (task.getWork_hours_id() == null) {
            listIterator.remove();
        }
    }

    WorkHoursManager workHoursManager = new WorkHoursManager();
    List<WorkHoursVO> worksHours_list = workHoursManager.consultarPorAgenda(personavo.getAgenda_id());
    request.setAttribute("tasks", task_list);
    request.setAttribute("works", worksHours_list);
    RequestDispatcher rd = getServletContext().getRequestDispatcher("/schedule.jsp");
    rd.forward(request, response);

}