List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:com.eeesys.frame.utils.IdcardTool.java
/** * 15?????18?/* www .j av a 2 s . c o m*/ * * @param idCard 15?? * @return 18?? */ public static String conver15CardTo18(String idCard) { String idCard18 = ""; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { // ? String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyMMdd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) cal.setTime(birthDate); // ?(?,2010) String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); // ? char[] cArr = idCard18.toCharArray(); if (cArr != null) { int[] iCard = converCharToInt(cArr); int iSum17 = getPowerSum(iCard); // ?? String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } } else { return null; } return idCard18; }
From source file:com.domain.java.util.IDCardUtils.java
/** * 15?????18?/*from w w w.ja v a2 s . c o m*/ * @param idCard 15?? * @return 18?? */ public static String convert15CardTo18(String idCard) { String idCard18; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { // ? String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyMMdd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) cal.setTime(birthDate); // ?(?,2010) String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); // ? char[] cArr = idCard18.toCharArray(); int[] iCard = convertCharToInt(cArr); int iSum17 = getPowerSum(iCard); // ?? String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } else { return null; } return idCard18; }
From source file:cn.wangsy.fast4j.util.IdcardUtils.java
/** * ?15????// w ww . ja va2s .c om * * @param idCard * ? * @return ?? */ public static boolean validateIdCard15(String idCard) { if (idCard.length() != CHINA_ID_MIN_LENGTH) { return false; } if (isNum(idCard)) { String proCode = idCard.substring(0, 2); if (cityCodes.get(proCode) == null) { return false; } String birthCode = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyyy").parse(CHINA_ID_MIN_PREFIX + birthCode.substring(0, 2)); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) cal.setTime(birthDate); if (!valiDate(cal.get(Calendar.YEAR), Integer.valueOf(birthCode.substring(2, 4)), Integer.valueOf(birthCode.substring(4, 6)))) { return false; } } else { return false; } return true; }
From source file:cn.wangsy.fast4j.util.IdcardUtils.java
/** * 15?????18?/* w w w . ja v a 2s . co m*/ * * @param idCard * 15?? * @return 18?? */ public static String conver15CardTo18(String idCard) { String idCard18 = ""; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { // ? String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyyyMMdd").parse(CHINA_ID_MIN_PREFIX + birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) cal.setTime(birthDate); // ?(?,2010) String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); // ? char[] cArr = idCard18.toCharArray(); if (cArr != null) { int[] iCard = converCharToInt(cArr); int iSum17 = getPowerSum(iCard); // ?? String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } } else { return null; } return idCard18; }
From source file:com.marand.thinkmed.medications.dto.report.TherapyDayReportUtils.java
public static String getTherapyApplicationColumnValue(List<AdministrationDto> therapyAdministrations, @Nonnull final TherapyDto order, @Nonnull final Date startDate, final int column, @Nonnull Locale locale) { final DateTime day = new DateTime(startDate).plusDays(column).withTimeAtStartOfDay(); final StringBuilder administrationString = new StringBuilder(); if (therapyAdministrations != null) { Collections.sort(therapyAdministrations, Comparator.comparing(AdministrationDto::getAdministrationTime)); for (final AdministrationDto administration : therapyAdministrations) { final DateTime administrationTime = administration.getAdministrationTime(); if (administrationTime != null && administrationTime.withTimeAtStartOfDay().isEqual(day)) { final StringBuilder dose = new StringBuilder(); if (administration.getAdministrationResult() == AdministrationResultEnum.DEFER) { dose.append(StringUtils.capitalize(getDictionaryEntry("administration.defer", locale))); if (administration.getNotAdministeredReason() != null && administration.getNotAdministeredReason().getName() != null) { dose.append(" - ").append(administration.getNotAdministeredReason().getName()); }// w w w . j av a 2 s . c om } else if (administration.getAdministrationResult() == AdministrationResultEnum.NOT_GIVEN) { dose.append(StringUtils.capitalize(getDictionaryEntry("administration.not.given", locale))); if (administration.getNotAdministeredReason() != null && administration.getNotAdministeredReason().getName() != null) { dose.append(" - ").append(administration.getNotAdministeredReason().getName()); } } else { if (administration instanceof StartAdministrationDto) { final TherapyDoseDto administeredDose = ((StartAdministrationDto) administration) .getAdministeredDose(); if (administeredDose != null && administeredDose.getNumerator() != null && administeredDose.getNumeratorUnit() != null) { try { dose.append(NumberFormatters.doubleFormatter2(locale) .valueToString(administeredDose.getNumerator()) + " " + administeredDose.getNumeratorUnit()); } catch (final ParseException e) { e.printStackTrace(); } } } else if (administration instanceof AdjustInfusionAdministrationDto) { final TherapyDoseDto administeredDose = ((AdjustInfusionAdministrationDto) administration) .getAdministeredDose(); if (administeredDose.getNumerator() != null && administeredDose.getNumeratorUnit() != null) { try { dose.append(NumberFormatters.doubleFormatter2(locale) .valueToString(administeredDose.getNumerator()) + " " + administeredDose.getNumeratorUnit()); } catch (ParseException e) { e.printStackTrace(); } } } else if (administration instanceof InfusionSetChangeDto) { //noinspection SwitchStatement switch (((InfusionSetChangeDto) administration).getInfusionSetChangeEnum()) { case INFUSION_SYRINGE_CHANGE: dose.append(getDictionaryEntry("infusion.syringe.change", locale)); break; case INFUSION_SYSTEM_CHANGE: dose.append(getDictionaryEntry("infusion.system.change", locale)); break; } } else if (administration instanceof StopAdministrationDto) { dose.append(getDictionaryEntry("infusion.stopped", locale)); } } if (administration.getComment() != null) { dose.append(" - ").append(administration.getComment()); } administrationString.append(String.format("<b>%02d:%02d<br></b>%s<br><br>", administrationTime.getHourOfDay(), administrationTime.getMinuteOfHour(), dose)); } } } return administrationString.toString(); }
From source file:de.da_sense.moses.client.abstraction.apks.ExternalApplication.java
/** * Convert a String to a Date./* w w w . j a va2s .c o m*/ * * @param date * the date as String (yyyy-MM-dd) * @return date */ private static Date convertStringDate(String date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date dateObject = null; try { if (date != null && date != "null") { dateObject = format.parse(date); } } catch (ParseException e) { e.printStackTrace(); } return dateObject; }
From source file:org.house.service.spider.WebSpider.java
public static EarthBasicDataJpa getEarthBasicData(final String countryName, final String countryId, final String queryCountryId, final int flag) throws UnsupportedEncodingException { final HttpPost httpPost = new HttpPost("http://www.laho.gov.cn/g4cdata/search/project/country.jsp"); setAjaxRequestHeader(httpPost);//from ww w . j a v a 2 s .c om final List<NameValuePair> parameters = Lists.newArrayList(); parameters.add(new BasicNameValuePair("country_name", countryName)); parameters.add(new BasicNameValuePair("country_id", countryId)); parameters.add(new BasicNameValuePair("countryId", queryCountryId)); parameters.add(new BasicNameValuePair("flag", "" + flag)); final UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(parameters); httpPost.setEntity(urlEncodedFormEntity); final String content = doHttpRequest(httpPost); if (content == null) { return null; } final EarthBasicDataJpa earthBasicDataJpa = new EarthBasicDataJpa(); earthBasicDataJpa.setEarthLicenseId(queryCountryId); final String tag1 = "??"; final String tag2 = "tab_style01_td\">"; final String tag3 = "</td>"; final int idx1 = content.indexOf(tag1); final int idx2 = content.indexOf(tag2, idx1 + tag1.length()); final int idx3 = content.indexOf(tag3, idx2 + tag2.length()); final String earthLicenseNo = content.substring(idx2 + tag2.length(), idx3); earthBasicDataJpa.setEarthLicenseNo(earthLicenseNo); final int idx4 = content.indexOf(tag2, idx3 + tag3.length()); final int idx5 = content.indexOf(tag3, idx4 + tag2.length()); final String location = content.substring(idx4 + tag2.length(), idx5); earthBasicDataJpa.setLocation(location); final int idx6 = content.indexOf(tag2, idx5 + tag3.length()); final int idx7 = content.indexOf(tag3, idx6 + tag2.length()); final String userr = content.substring(idx6 + tag2.length(), idx7); earthBasicDataJpa.setUserr(userr); final int idx8 = content.indexOf(tag2, idx7 + tag3.length()); final int idx9 = content.indexOf(tag3, idx8 + tag2.length()); final String earthNo = content.substring(idx8 + tag2.length(), idx9); earthBasicDataJpa.setEarthNo(earthNo); final int idx10 = content.indexOf(tag2, idx9 + tag3.length()); final int idx11 = content.indexOf(tag3, idx10 + tag2.length()); final String graphNo = content.substring(idx10 + tag2.length(), idx11); earthBasicDataJpa.setGraphNo(graphNo); final int idx12 = content.indexOf(tag2, idx11 + tag3.length()); final int idx13 = content.indexOf(tag3, idx12 + tag2.length()); final String usagee = content.substring(idx12 + tag2.length(), idx13); earthBasicDataJpa.setUsagee(usagee); final int idx14 = content.indexOf(tag2, idx13 + tag3.length()); final int idx15 = content.indexOf(tag3, idx14 + tag2.length()); final String levell = content.substring(idx14 + tag2.length(), idx15); earthBasicDataJpa.setLevell(levell); final int idx16 = content.indexOf(tag2, idx15 + tag3.length()); final int idx17 = content.indexOf(tag3, idx16 + tag2.length()); final String borrowFrom = content.substring(idx16 + tag2.length(), idx17); Date bfDate = null; try { bfDate = new SimpleDateFormat("yyyy-MM-dd").parse(borrowFrom); } catch (final ParseException e) { e.printStackTrace(); } earthBasicDataJpa.setBorrowFrom(bfDate); final int idx18 = content.indexOf(tag2, idx17 + tag3.length()); final int idx19 = content.indexOf(tag3, idx18 + tag2.length()); final String useRightKind = content.substring(idx18 + tag2.length(), idx19); earthBasicDataJpa.setUseRightKind(useRightKind); final int idx20 = content.indexOf(tag2, idx19 + tag3.length()); final int idx21 = content.indexOf(tag3, idx20 + tag2.length()); final String useArea = content.substring(idx20 + tag2.length(), idx21); earthBasicDataJpa.setUseArea(useArea); final int idx22 = content.indexOf(tag2, idx21 + tag3.length()); final int idx23 = content.indexOf(tag3, idx22 + tag2.length()); final String shareArea = content.substring(idx22 + tag2.length(), idx23); earthBasicDataJpa.setShareArea(shareArea); final int idx24 = content.indexOf(tag2, idx23 + tag3.length()); final int idx25 = content.indexOf(tag3, idx24 + tag2.length()); final String licenseOffice = content.substring(idx24 + tag2.length(), idx25); earthBasicDataJpa.setLicenseOffice(licenseOffice); final int idx26 = content.indexOf(tag2, idx25 + tag3.length()); final int idx27 = content.indexOf(tag3, idx26 + tag2.length()); final String licenseIssueDate = content.substring(idx26 + tag2.length(), idx27); Date lidDate = new Date(0); // licenseIssueDate? try { lidDate = new SimpleDateFormat("yyyy-MM-dd").parse(licenseIssueDate); } catch (final ParseException e) { e.printStackTrace(); } earthBasicDataJpa.setLicenseIssueDate(lidDate); return earthBasicDataJpa; }
From source file:org.house.service.spider.WebSpider.java
public static PreSellLicenseDataJpa getPreSellLicenseData(final String projectId, final String preSellLicenseId) { final HttpGet httpGet = new HttpGet("http://www.laho.gov.cn/g4cdata/search/project/preSell.jsp?pjID=" + projectId + "&presell=" + preSellLicenseId + "&maxPrice=&groundPrice="); setAjaxRequestHeader(httpGet);// w w w . j a v a 2 s .c o m final String content = doHttpRequest(httpGet); if (content == null) { return null; } final PreSellLicenseDataJpa preSellLicenseDataJpa = new PreSellLicenseDataJpa(); preSellLicenseDataJpa.setPreSellLicenseId(preSellLicenseId); final String tag1 = ""; final String tag2 = "tab_style01_td\">"; final String tag3 = "</p></td>"; final String tag4 = "<p align=\"left\">"; final String tag5 = "box_tab_style02_td\" >"; final String tag6 = ""; final String tag7 = "</td>"; final String tag8 = "?"; final String tag9 = "tab_style01_td\" >"; final int idx1 = content.indexOf(tag1); final int idx2 = content.indexOf(tag2, idx1 + tag1.length()); final int idx3 = content.indexOf(tag3, idx2 + tag2.length()); final int buildingCount = Utils .tryParseInteger(content.substring(idx2 + tag2.length() + tag4.length(), idx3)); preSellLicenseDataJpa.setBuildingCount(buildingCount); final int idx4 = content.indexOf(tag9, idx3 + tag3.length()); final int idx5 = content.indexOf(tag3, idx4 + tag9.length()); final String buildingHouse = content.substring(idx4 + tag9.length() + tag4.length(), idx5); preSellLicenseDataJpa.setBuildingHouse(buildingHouse); final int idx6 = content.indexOf(tag2, idx5 + tag3.length()); final int idx7 = content.indexOf(tag3, idx6 + tag2.length()); final String builtHouse = content.substring(idx6 + tag2.length() + tag4.length(), idx7); preSellLicenseDataJpa.setBuiltHouse(builtHouse); final int idx8 = content.indexOf(tag2, idx7 + tag3.length()); final int idx9 = content.indexOf(tag3, idx8 + tag2.length()); final int currentPhase = Utils .tryParseInteger(content.substring(idx8 + tag2.length() + tag4.length(), idx9)); preSellLicenseDataJpa.setCurrentPhase(currentPhase); final int idx10 = content.indexOf(tag2, idx9 + tag3.length()); final int idx11 = content.indexOf(tag3, idx10 + tag2.length()); final String currentPhaseBuildingArea = content.substring(idx10 + tag2.length() + tag4.length(), idx11); preSellLicenseDataJpa.setCurrentPhaseBuildingArea(currentPhaseBuildingArea); final int idx12 = content.indexOf(tag2, idx11 + tag3.length()); final int idx13 = content.indexOf(tag3, idx12 + tag2.length()); final String areaUpGround = content.substring(idx12 + tag2.length() + tag4.length(), idx13); preSellLicenseDataJpa.setAreaUpGround(areaUpGround); final int idx14 = content.indexOf(tag2, idx13 + tag3.length()); final int idx15 = content.indexOf(tag3, idx14 + tag2.length()); final String areaUnderGround = content.substring(idx14 + tag2.length() + tag4.length(), idx15); preSellLicenseDataJpa.setAreaUnderGround(areaUnderGround); final int idx16 = content.indexOf(tag2, idx15 + tag3.length()); final int idx17 = content.indexOf(tag3, idx16 + tag2.length()); final int unitCount = Utils .tryParseInteger(content.substring(idx16 + tag2.length() + tag4.length(), idx17)); preSellLicenseDataJpa.setUnitCount(unitCount); final int idx18 = content.indexOf(tag2, idx17 + tag3.length()); final int idx19 = content.indexOf(tag3, idx18 + tag2.length()); final String totalBuidingArea = content.substring(idx18 + tag2.length() + tag4.length(), idx19); preSellLicenseDataJpa.setTotalBuidingArea(totalBuidingArea); final int idx20 = content.indexOf(tag2, idx19 + tag3.length()); final int idx21 = content.indexOf(tag3, idx20 + tag2.length()); final String contactPersion = content.substring(idx20 + tag2.length() + tag4.length(), idx21); preSellLicenseDataJpa.setContactPersion(contactPersion); final int idx22 = content.indexOf(tag2, idx21 + tag3.length()); final int idx23 = content.indexOf(tag3, idx22 + tag2.length()); final String mortgage = content.substring(idx22 + tag2.length() + tag4.length(), idx23); preSellLicenseDataJpa.setMortgage(mortgage); final int idx24 = content.indexOf(tag2, idx23 + tag3.length()); final int idx25 = content.indexOf(tag3, idx24 + tag2.length()); final String supportingArea = content.substring(idx24 + tag2.length() + tag4.length(), idx25); preSellLicenseDataJpa.setSupportingArea(supportingArea); final int idx26 = content.indexOf(tag5, idx25 + tag3.length()); final int idx27 = content.indexOf(tag3, idx26 + tag5.length()); final String validateFrom = content.substring(idx26 + tag5.length() + tag4.length(), idx27); preSellLicenseDataJpa.setValidateFrom(validateFrom); final int idx28 = content.indexOf(tag5, idx27 + tag3.length()); final int idx29 = content.indexOf(tag3, idx28 + tag5.length()); final String validateTo = content.substring(idx28 + tag5.length() + tag4.length(), idx29); preSellLicenseDataJpa.setValidateTo(validateTo); final int idx30 = content.indexOf(tag2, idx29 + tag3.length()); final int idx31 = content.indexOf(tag3, idx30 + tag2.length()); final String licenseIssueDate = content.substring(idx30 + tag2.length() + tag4.length(), idx31); Date lidDate = new Date(0); // licenseIssueDate? try { lidDate = new SimpleDateFormat("yyyy-MM-dd").parse(licenseIssueDate); } catch (final ParseException e) { e.printStackTrace(); } preSellLicenseDataJpa.setLicenseIssueDate(lidDate); final int idx32 = content.indexOf(tag6, idx31 + tag3.length()); final int idx33 = content.indexOf(tag2, idx32 + tag6.length()); final int idx34 = content.indexOf(tag7, idx33 + tag2.length()); final int distributeOfResidentialCount = Utils .tryParseInteger(content.substring(idx33 + tag2.length(), idx34)); preSellLicenseDataJpa.setDistributeOfResidentialCount(distributeOfResidentialCount); final int idx35 = content.indexOf(tag2, idx34 + tag7.length()); final int idx36 = content.indexOf(tag7, idx35 + tag2.length()); final int distributeOfBussinessCount = Utils .tryParseInteger(content.substring(idx35 + tag2.length(), idx36)); preSellLicenseDataJpa.setDistributeOfBussinessCount(distributeOfBussinessCount); final int idx37 = content.indexOf(tag2, idx36 + tag7.length()); final int idx38 = content.indexOf(tag7, idx37 + tag2.length()); final int distributeOfOfficeCount = Utils.tryParseInteger(content.substring(idx37 + tag2.length(), idx38)); preSellLicenseDataJpa.setDistributeOfOfficeCount(distributeOfOfficeCount); final int idx39 = content.indexOf(tag2, idx38 + tag7.length()); final int idx40 = content.indexOf(tag7, idx39 + tag2.length()); final int distributeOfParkingCount = Utils.tryParseInteger(content.substring(idx39 + tag2.length(), idx40)); preSellLicenseDataJpa.setDistributeOfParkingCount(distributeOfParkingCount); final int idx41 = content.indexOf(tag2, idx40 + tag7.length()); final int idx42 = content.indexOf(tag7, idx41 + tag2.length()); final int distributeOfOtherCount = Utils.tryParseInteger(content.substring(idx41 + tag2.length(), idx42)); preSellLicenseDataJpa.setDistributeOfOtherCount(distributeOfOtherCount); final int idx43 = content.indexOf(tag8, idx42 + tag7.length()); final int idx44 = content.indexOf(tag2, idx43 + tag8.length()); final int idx45 = content.indexOf(tag7, idx44 + tag2.length()); final String distributeOfResidentialArea = content.substring(idx44 + tag2.length(), idx45); preSellLicenseDataJpa.setDistributeOfResidentialArea(distributeOfResidentialArea); final int idx46 = content.indexOf(tag2, idx45 + tag7.length()); final int idx47 = content.indexOf(tag7, idx46 + tag2.length()); final String distributeOfBussinessArea = content.substring(idx46 + tag2.length(), idx47); preSellLicenseDataJpa.setDistributeOfBussinessArea(distributeOfBussinessArea); final int idx48 = content.indexOf(tag2, idx47 + tag7.length()); final int idx49 = content.indexOf(tag7, idx48 + tag2.length()); final String distributeOfOfficeArea = content.substring(idx48 + tag2.length(), idx49); preSellLicenseDataJpa.setDistributeOfOfficeArea(distributeOfOfficeArea); final int idx50 = content.indexOf(tag2, idx49 + tag7.length()); final int idx51 = content.indexOf(tag7, idx50 + tag2.length()); final String distributeOfParkingArea = content.substring(idx50 + tag2.length(), idx51); preSellLicenseDataJpa.setDistributeOfParkingArea(distributeOfParkingArea); final int idx52 = content.indexOf(tag2, idx51 + tag7.length()); final int idx53 = content.indexOf(tag7, idx52 + tag2.length()); final String distributeOfOtherArea = content.substring(idx52 + tag2.length(), idx53); preSellLicenseDataJpa.setDistributeOfOtherArea(distributeOfOtherArea); return preSellLicenseDataJpa; }
From source file:com.wkb.core.util.IdcardUtils.java
/** * ???,//from ww w . ja va 2s . c om * * @param idCard * ? * @return */ public static int getAccurateAgeByIdCard(String idCard) { int iAge = getAgeByIdCard(idCard); String birthDay = getBirthByIdCard(idCard); Date birthDate = null; try { birthDate = sdf.parse(birthDay); } catch (ParseException e) { e.printStackTrace(); } Calendar birthCal = Calendar.getInstance(); birthCal.setTime(birthDate); birthCal.set(Calendar.HOUR_OF_DAY, 0); birthCal.set(Calendar.MINUTE, 0); birthCal.set(Calendar.SECOND, 0); Calendar curCal = Calendar.getInstance(); if (curCal.before(birthCal)) iAge = iAge - 1; return iAge; }
From source file:com.tenmiles.helpstack.gears.HSDeskGear.java
protected static Date parseTime(String dateString) { Date givenTimeDate = null;//from w w w . j a v a 2 s .c om try { givenTimeDate = parseUTCString(dateString, "yyyy-MM-dd'T'HH:mm:ss'Z'"); } catch (ParseException e) { try { givenTimeDate = parseUTCString(dateString, "yyyy-MM-dd"); } catch (ParseException e1) { try { givenTimeDate = parseUTCString(dateString, "yyyy-MM-dd HH:mm:ss.SSSSZ"); } catch (ParseException e2) { e2.printStackTrace(); } } } return givenTimeDate; }