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.upscale.front.service.util.TextExtractionUtil.java

public Date extractDOB(String text, String type) {

    if (type.equals("PANCARD")) {
        Pattern pattern = Pattern.compile("(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\\d\\d");
        String result = null;//from w w w .j  av  a2  s . c  o  m
        String[] data = org.apache.commons.lang.StringUtils.split(text, "\n");
        for (String str : data) {
            Matcher matcher = pattern.matcher(str);
            if (matcher.matches())
                result = str;
        }

        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        Date dob = new Date();
        try {
            dob = df.parse(result);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return dob;
    } else
        return null;

}

From source file:fr.bde_eseo.eseomega.events.tickets.model.ShuttleItem.java

public Date getParsedDate(String datetime) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.FRANCE);
    Date date = null;/*from w ww.  j  a  v  a 2  s.c  o  m*/
    try {
        date = format.parse(datetime);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:org.mule.module.http.functional.listener.HttpListenerGlobalResponseBuilderTestCase.java

public boolean isDateValid(String dateToValidate) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
    try {/*from   w  w w .  j  a  v  a 2s  .  co  m*/
        sdf.parse(dateToValidate);
    } catch (ParseException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}

From source file:com.oasis.test.driver.DriverServiceTest.java

private DriverSO getSo() {
    DriverSO so = new DriverSO();
    so.setStatus(DriverStatus.NORMAL);//from   ww w  . j a  va  2 s . co m
    so.setLicense("A");

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    try {
        so.setPeriodStart(df.parse("2008-06-21"));
        so.setPeriodEnd(df.parse("2015-10-08"));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return so;
}

From source file:org.openmrs.module.laboratory.web.controller.editresult.SearchCompletedTestsController.java

@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.GET)
public String searchTest(@RequestParam(value = "date", required = false) String dateStr,
        @RequestParam(value = "phrase", required = false) String phrase,
        @RequestParam(value = "investigation", required = false) Integer investigationId,
        HttpServletRequest request, Model model) {
    LaboratoryService ls = (LaboratoryService) Context.getService(LaboratoryService.class);
    Concept investigationConcept = Context.getConceptService().getConcept(investigationId);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Date date = null;//from w  w w.j av a2  s  .co m
    try {
        date = sdf.parse(dateStr);

        Map<Concept, Set<Concept>> testTreeMap = (Map<Concept, Set<Concept>>) request.getSession()
                .getAttribute(LaboratoryConstants.SESSION_TEST_TREE_MAP);
        Set<Concept> allowableTests = new HashSet<Concept>();
        if (investigationConcept != null) {
            allowableTests = testTreeMap.get(investigationConcept);
        } else {
            for (Concept c : testTreeMap.keySet()) {
                allowableTests.addAll(testTreeMap.get(c));
            }
        }

        List<LabTest> laboratoryTests = ls.getCompletedLaboratoryTests(date, phrase, allowableTests);
        List<TestModel> tests = LaboratoryUtil.generateModelsFromTests(laboratoryTests, testTreeMap);
        model.addAttribute("tests", tests);
        model.addAttribute("testNo", tests.size());
    } catch (ParseException e) {
        e.printStackTrace();
        System.out.println("Error when parsing order date!");
        return null;
    }
    return "/module/laboratory/editresult/search";
}

From source file:org.openmrs.module.laboratory.web.controller.worklist.SearchController.java

@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.GET)
public String searchTest(@RequestParam(value = "date", required = false) String dateStr,
        @RequestParam(value = "phrase", required = false) String phrase,
        @RequestParam(value = "investigation", required = false) Integer investigationId,
        HttpServletRequest request, Model model) {
    LaboratoryService ls = (LaboratoryService) Context.getService(LaboratoryService.class);
    Concept investigation = Context.getConceptService().getConcept(investigationId);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Date date = null;//w w  w.  j  ava2 s. co  m
    try {
        date = sdf.parse(dateStr);
        Map<Concept, Set<Concept>> testTreeMap = (Map<Concept, Set<Concept>>) request.getSession()
                .getAttribute(LaboratoryConstants.SESSION_TEST_TREE_MAP);
        Set<Concept> allowableTests = new HashSet<Concept>();
        if (investigation != null) {
            allowableTests = testTreeMap.get(investigation);
        } else {
            for (Concept c : testTreeMap.keySet()) {
                allowableTests.addAll(testTreeMap.get(c));
            }
        }
        List<LabTest> laboratoryTests = ls.getAcceptedLaboratoryTests(date, phrase, allowableTests);
        List<TestModel> tests = LaboratoryUtil.generateModelsFromTests(laboratoryTests, testTreeMap);
        //ghanshyam 04/07/2012 New Requirement #277
        Collections.sort(tests);
        model.addAttribute("tests", tests);
        model.addAttribute("testNo", tests.size());
    } catch (ParseException e) {
        e.printStackTrace();
        System.out.println("Error when parsing order date!");
        return null;
    }
    return "/module/laboratory/worklist/search";
}

From source file:com.hihframework.core.utils.CurrencyConverter.java

/**
 * Convert a String to a Double and a Double to a String
 *
 * @param type the class type to output/*  w  w w  . j  av a  2s  . c  o m*/
 * @param value the object to convert
 * @return object the converted object (Double or String)
 */
public final Object convert(final Class<?> type, final Object value) {
    // for a null value, return null
    if (value == null) {
        return null;
    } else {
        if (value instanceof String) {
            if (log.isDebugEnabled()) {
                log.debug("value (" + value + ") instance of String");
            }

            try {
                if (StringUtils.isNotEmpty(String.valueOf(value))) {
                    return null;
                }

                if (log.isDebugEnabled()) {
                    log.debug("converting '" + value + "' to a decimal");
                }

                //formatter.setDecimalSeparatorAlwaysShown(true);
                Number num = formatter.parse(String.valueOf(value));

                return new Double(num.doubleValue());
            } catch (ParseException pe) {
                pe.printStackTrace();
            }
        } else if (value instanceof Double) {
            if (log.isDebugEnabled()) {
                log.debug("value (" + value + ") instance of Double");
                log.debug("returning double: " + formatter.format(value));
            }

            return formatter.format(value);
        }
    }

    throw new ConversionException("Could not convert " + value + " to " + type.getName() + "!");
}

From source file:com.oasis.test.driver.DriverServiceTest.java

private DriverVO getVo() {
    DriverSO so = new DriverSO();
    PageList<DriverVO> page = service.getPageList(so);
    DriverVO vo = page.getList().get(0);
    vo.setName("");
    vo.setCode("zh001");
    vo.setAllowedTruck(AllowedTruck.B);/*  w  w  w .j a va  2  s.c  om*/
    vo.setLicense("A 7985");
    vo.setLicenseDate(Calendar.getInstance().getTime());
    vo.setStatus(DriverStatus.NORMAL);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    try {
        vo.setPeriodStart(df.parse("2003-06-21"));
        vo.setPeriodEnd(df.parse("2017-10-08"));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return vo;
}

From source file:org.hil.core.dao.hibernate.ChildrenUnder1DaoHibernate.java

public List<ChildrenUnder1> createChildrenUnder1InCommunesByDistrict(String time, Long communeId,
        District district) {//  w ww  . j a v  a 2 s . co  m
    List<Commune> communes = communeDaoExt.findByDistrictId(district.getId());
    List<ChildrenUnder1> listCommunes = new ArrayList<ChildrenUnder1>();
    for (Commune c : communes) {
        ChildrenUnder1 cu = new ChildrenUnder1();
        cu.setCommune(c);
        SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
        try {
            Date rdate = format.parse("01/" + time);
            cu.setTime(rdate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        cu = childrenUnder1Dao.save(cu);
        if (communeId != null) {
            if (cu.getCommune().getId().compareTo(communeId) == 0)
                listCommunes.add(cu);
        } else
            listCommunes.add(cu);
    }
    return listCommunes;
}

From source file:edu.gmu.csd.validation.Validation.java

public void validateDateOfSurvey(FacesContext context, UIComponent componentToValidate, Object value)
        throws ValidationException {
    boolean isDateValid = false;
    String dateOfSurvey = (String) value;

    SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
    sdf.setLenient(false);/*from  w  w w.  j av a 2s  .  c  om*/

    try {
        sdf.parse(dateOfSurvey);
        isDateValid = true;
    } catch (ParseException pexp) {
        pexp.printStackTrace();
        isDateValid = false;
    }

    if (!isDateValid && StringUtils.isNotEmpty(dateOfSurvey)) {
        FacesMessage message = new FacesMessage("Date of survey should be of valid format.");
        throw new ValidatorException(message);
    }
}