List of usage examples for java.text DateFormat parse
public Date parse(String source) throws ParseException
From source file:th.co.geniustree.dental.controller.DetailHealController.java
@RequestMapping(value = "/loaddetailheal/searchdetailhealforbill", method = RequestMethod.POST) public Page<DetailHeal> searchForBill(@RequestBody SearchData searchData, Pageable pageable) throws ParseException { String keyword = searchData.getKeyword(); String searchBy = searchData.getSearchBy(); Page<DetailHeal> detailHeals = null; if ("".equals(searchBy)) { detailHeals = detailHealService.searchByPatientForBill(keyword, pageable); }/*from w w w . ja va2 s.c o m*/ if ("".equals(searchBy)) { detailHeals = detailHealService.searchByDoctorForBill(keyword, pageable); } if ("?".equals(searchBy)) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US); Date keywordDate = df.parse(keyword); detailHeals = detailHealService.searchByDateHealForBill(keywordDate, pageable); } return detailHeals; }
From source file:th.co.geniustree.dental.controller.DetailHealController.java
@RequestMapping(value = "/countsearchdetailheal", method = RequestMethod.POST) public long countSearchDetailHeal(@RequestBody SearchData searchData) throws ParseException { long count = 0; String keyword = searchData.getKeyword(); String searchBy = searchData.getSearchBy(); Page<DetailHeal> detailHeals = null; if ("".equals(searchBy)) { count = detailHealRepo.count(DetailHealSpec.patientLike("%" + keyword + "%")); }//from w w w . j a v a2 s . co m if ("".equals(searchBy)) { count = detailHealRepo.count(DetailHealSpec.doctorLike("%" + keyword + "%")); } if ("Date?Heal".equals(searchBy)) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US); Date keywordDate = df.parse(keyword); count = detailHealRepo.count(DetailHealSpec.dateHealLike(keywordDate)); } return count; }
From source file:th.co.geniustree.dental.controller.DetailHealController.java
@RequestMapping(value = "/countsearchdetailhealforbill", method = RequestMethod.POST) public long countSearchDetailHealForBill(@RequestBody SearchData searchData) throws ParseException { long count = 0; String keyword = searchData.getKeyword(); String searchBy = searchData.getSearchBy(); Page<DetailHeal> detailHeals = null; if ("".equals(searchBy)) { count = detailHealRepo.count(DetailHealSpec.patientLikeForBill("%" + keyword + "%")); }/*from w w w . ja v a 2 s .c o m*/ if ("".equals(searchBy)) { count = detailHealRepo.count(DetailHealSpec.doctorLikeForBill("%" + keyword + "%")); } if ("Date?Heal".equals(searchBy)) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.US); Date keywordDate = df.parse(keyword); count = detailHealRepo.count(DetailHealSpec.dateHealLikeForBill(keywordDate)); } return count; }
From source file:com.chevres.rss.worker.feedupdater.RssHandler.java
@Override public void endElement(String uri, String localName, String qName) { if (this.currentArticle != null && this.articles != null) { try {// w w w . jav a 2 s .c o m if (qName.equals("content:encoded")) qName = "content"; switch (qName.toLowerCase()) { case "title": String title = this.stringBuilder.toString(); title = title.substring(0, Math.min(title.length(), 500)); this.currentArticle.setTitle(title); break; case "pubdate": String pubDate = this.stringBuilder.toString(); DateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");//TODO a ameliorer Date date = formatter.parse(pubDate); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.MILLISECOND, 0); this.currentArticle.setPubDate(new java.sql.Timestamp(date.getTime())); break; case "link": String link = this.stringBuilder.toString(); this.currentArticle.setLink(link); break; case "description": String description = this.stringBuilder.toString(); this.currentArticle.setPreviewContent(description); break; case "content": String content = this.stringBuilder.toString(); this.currentArticle.setFullContent(content); break; } } catch (Exception e) { System.out.println(e.getMessage()); } } }
From source file:com.eryansky.common.utils.DateUtil.java
/** * /*from w ww . j ava 2 s . c o m*/ * @date1?date2? ? 2008-08-08 16:16:34 * @param date1 * @param date2 * @return */ public static boolean isDateBefore(String date1, String date2) { try { DateFormat df = DateFormat.getDateTimeInstance(); return df.parse(date1).before(df.parse(date2)); } catch (ParseException e) { System.out.print("[SYS] " + e.getMessage()); return false; } }
From source file:com.netflix.genie.common.util.JsonDateDeserializer.java
/** * {@inheritDoc}/*from w ww .j ava2 s. c o m*/ */ @Override public Date deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { final DateFormat format = new ISO8601DateFormat(); final String text = parser.getText(); if (StringUtils.isBlank(text)) { return null; } try { return format.parse(text); } catch (final ParseException pe) { throw new IOException(pe); } }
From source file:com.googlecode.jsfFlex.component.ext.AbstractFlexUIDateField.java
@Override public void decode(FacesContext context) { super.decode(context); java.util.Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap(); String selectedDateId = getId() + SELECTED_DATE_ID_APPENDED; String selectedDateUpdateVal = requestMap.get(selectedDateId); if (selectedDateUpdateVal != null && selectedDateUpdateVal.length() > 0) { /*/*from w w w . j a v a 2 s. c o m*/ * HACK: Since ActionScript returns date in format of "Thu Aug 23 00:00:00 GMT-0700 2009" * and "EEE MMM dd HH:mm:ss zZ yyyy" pattern doesn't seem to match it within SimpleDateFormat, * place a space between z + Z */ int dashIndex = selectedDateUpdateVal.indexOf("-"); if (dashIndex != -1) { selectedDateUpdateVal = selectedDateUpdateVal.substring(0, dashIndex) + " " + selectedDateUpdateVal.substring(dashIndex); } Calendar instance = Calendar.getInstance(); try { DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_DEFAULT); dateFormat.setLenient(true); instance.setTime(dateFormat.parse(selectedDateUpdateVal)); setSelectedDate(instance); } catch (ParseException parsingException) { setValid(false); context.addMessage(getId(), new FacesMessage("Parsing exception for value : " + selectedDateUpdateVal)); _log.error("Parsing exception for value : " + selectedDateUpdateVal, parsingException); } } }
From source file:com.haulmont.chile.core.datatypes.impl.DateDatatype.java
@Override public Date parse(String value, Locale locale) throws ParseException { if (StringUtils.isBlank(value)) { return null; }/*from w ww. j av a2s . c om*/ FormatStrings formatStrings = AppBeans.get(FormatStringsRegistry.class).getFormatStrings(locale); if (formatStrings == null) { return parse(value); } DateFormat format = new SimpleDateFormat(formatStrings.getDateFormat()); format.setLenient(false); return normalize(format.parse(value.trim())); }
From source file:de.tudarmstadt.ukp.argumentation.data.roomfordebate.NYTimesArticleExtractor.java
public Article extractArticle(String html) throws ParseException, IOException { Article result = new Article(); Document doc = Jsoup.parse(html, getBaseName()); Element element;//from ww w . j a v a2 s. co m try { element = doc.select("article.rfd").iterator().next(); } catch (NoSuchElementException exception) { throw new IOException("Cannot find article.rfd element"); } // System.out.println(element); String dateText = element.select("p.pubdate").text().replaceAll("Updated[\\s]+", ""); // time try { DateFormat df = new SimpleDateFormat("MMM dd, yyyy, hh:mm aaa", Locale.ENGLISH); Date date = df.parse(dateText); result.setTimestamp(date); } catch (ParseException e) { // June 24, 2015 DateFormat df = new SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH); Date date = df.parse(dateText); result.setTimestamp(date); } // title result.setTitle(TextCleaningUtils.normalizeWithParagraphs(element.select("h1").text())); // text StringBuilder sb = new StringBuilder(); for (Element p : element.select("div.nytint-post > p")) { sb.append(p.text()); sb.append("\n"); } result.setText(TextCleaningUtils.normalizeWithParagraphs(sb.toString())); // debate title result.setDebateTitle(TextCleaningUtils .normalizeWithParagraphs(doc.select("div.nytint-discussion-overview > h2").text())); // debate url result.setDebateUrl(doc.select("div.nytint-discussion-overview > h2 > a").iterator().next().attr("href")); // document url result.setUrl(doc.select("meta[name=communityAssetURL]").attr("content")); // debate description result.setDebateDescription(TextCleaningUtils .normalizeWithParagraphs(((TextNode) doc.select("div.nytint-discussion-overview > p").iterator() .next().childNodes().iterator().next()).text())); // aurhor result.setAuthor(element.select("div.nytint-mugshots > img").iterator().next().attr("alt")); // topics for (Element a : element.select("p.nytint-tags > a")) { result.getTopics().add(a.attr("href")); } return result; }
From source file:com.spend.spendService.DomainLearning.java
private void GetNewQuery() { try {/*from w w w .ja v a 2 s.c om*/ TimerTask timertask = new TimerTask() { public void run() { try { domainList = new ArrayList<String>(); String[] seList = getSearchEngineNamesArray(); /* get urls from seedurlraw table */ PreparedStatement psmt = con.prepareStatement("SELECT url FROM seedurlraw"); ResultSet rs = psmt.executeQuery(); String regex = "[/]"; String regex2 = "[.]"; String PLDomain; while (rs.next()) { PLDomain = rs.getString("url"); PLDomain = PLDomain.replaceAll("http://|https://", ""); Pattern p = Pattern.compile(regex); Matcher m = p.matcher(PLDomain); if (m.find()) { PLDomain = PLDomain.substring(0, m.start()); } Pattern p2 = Pattern.compile(regex2); Matcher m2 = p2.matcher(PLDomain); int count = 0; while (m2.find()) { count++; } m2 = p2.matcher(PLDomain); if (count > 1 && m2.find()) { PLDomain = PLDomain.substring(m2.end()); } //System.out.println(PLDomain); if (!domainList.contains(PLDomain)) { domainList.add(PLDomain); newQuery = "sparql endpoint site:" + PLDomain; for (Object se : seList) { PreparedStatement psmt1 = con.prepareStatement( "INSERT INTO searchqueue(searchText,disabled,searchEngineName) VALUES(?,0,?);"); psmt1.setString(1, newQuery); psmt1.setString(2, se.toString()); psmt1.executeUpdate(); psmt1.close(); } } } } catch (Exception ex) { System.out .println("DomainLearning.java timertask run function SQL ERROR " + ex.getMessage()); } } }; Timer timer = new Timer(); DateFormat dateformat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); Date date = dateformat.parse("20-07-2017 00:00:00"); // set date and time timer.schedule(timertask, date, 1000 * 60 * 60 * 24 * 7); // for a week 1000*60*60*24*7 } catch (Exception ex) { System.out.println("DomainLearning.java GetNewQuery function ERROR " + ex.getMessage()); } }