List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:messenger.YahooFinanceAPI.java
private Date transDate(String YYMMDD) { SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); Calendar cal = Calendar.getInstance(); try {/*w w w . j ava 2 s . com*/ cal.setTime(dateFormat.parse(YYMMDD)); } catch (ParseException e) { e.printStackTrace(); } return cal.getTime(); }
From source file:messenger.YahooFinanceAPI.java
private Date getToday() { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); Calendar cal = Calendar.getInstance(); try {/*from w w w.j ava 2 s. c om*/ Date today = new Date(); cal.setTime(dateFormat.parse(dateFormat.format(today))); } catch (ParseException e) { e.printStackTrace(); } return cal.getTime(); }
From source file:AIR.Common.Sql.UnitTestDateUtilDll.java
public UnitTestDateUtilDll() { String baseLineDateTime = appSettings.get("unitTests.baseLineDateTime"); try {// w w w. ja v a 2 s.co m _baseLineDate.setTime(new SimpleDateFormat(DB_DATETIME_FORMAT).parse(baseLineDateTime)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); _logger.error("Could not convert date time to a proper time: " + (StringUtils.isEmpty(baseLineDateTime) ? "Value passed is null. Set baseline datetime in configuration." : baseLineDateTime)); } }
From source file:controllers.MailController.java
public Result sendMail() { JsonNode json = request().body().asJson(); if (json == null) { return Common.badRequestWrapper("mail not sent, expecting Json data"); }/* w ww . ja v a2 s.co m*/ String fromUserMail = json.path("fromUserMail").asText(); String toUserMail = json.path("toUserMail").asText(); User fromUser = userRepository.findByEmail(fromUserMail); User toUser = userRepository.findByEmail(toUserMail); if (fromUser == null || toUser == null) { Map<String, String> map = new HashMap<>(); map.put("error", "No Access!"); String error = new Gson().toJson(map); return ok(error); } String mailTitle = json.path("mailTitle").asText(); String mailContent = json.path("mailContent").asText(); String dateString = json.path("mailDate").asText(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); Date mailDate = new Date(); try { mailDate = dateFormat.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } Mail mail = new Mail(fromUserMail, toUserMail, mailTitle, mailContent, mailDate); mailRepository.save(mail); return created(new Gson().toJson("success")); }
From source file:org.openmrs.module.mclinic.web.controller.form.SyncLoggerController.java
@RequestMapping(value = "/module/mclinic/syncLog", method = RequestMethod.POST) public String changeLogDate(HttpSession httpSession, @RequestParam(required = false) String logDate) { if (logDate != null && logDate.trim().length() > 0) { try {//from ww w . j av a 2 s . co m syncLogDate = df.parse(logDate); } catch (ParseException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Invalid date format"); e.printStackTrace(); } } else httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "No Date selected"); return "redirect:syncLog.list"; }
From source file:org.openmrs.module.xformshelper.web.controller.SyncLoggerController.java
@RequestMapping(value = "/module/xformshelper/syncLog", method = RequestMethod.POST) public String changeLogDate(HttpSession httpSession, @RequestParam(required = false) String logDate) { if (logDate != null && logDate.trim().length() > 0) { try {//from w w w .j a v a 2 s .co m syncLogDate = df.parse(logDate); } catch (ParseException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Invalid date format"); e.printStackTrace(); } } else httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "No Date selected"); return "redirect:syncLog.list"; }
From source file:org.openmrs.module.amrsmobileforms.web.controller.SyncLogController.java
@RequestMapping(value = "/module/amrsmobileforms/syncLog", method = RequestMethod.POST) public String changeLogDate(HttpSession httpSession, @RequestParam String logDate) { if (logDate.trim().length() > 0) { try {// www . j a v a 2 s. co m syncLogDate = df.parse(logDate); } catch (ParseException e) { httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Invalid date format"); e.printStackTrace(); } } else httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "No Date selected"); return "redirect:syncLog.list"; }
From source file:org.noorganization.instalistsynch.controller.local.dba.impl.ClientLogDbController.java
@Override public List<LogInfo> getElementByUuid(String _uuid, eActionType _actionType, eModelType _modelType, String _time) {/*from w w w.j ava 2 s .c om*/ Cursor cursor = mContentResolver.query(Uri.withAppendedPath(InstalistProvider.BASE_CONTENT_URI, "log"), LogInfo.COLUMN.ALL_COLUMNS, LogInfo.COLUMN.ITEM_UUID + " LIKE ? AND " + LogInfo.COLUMN.ACTION + " = ? AND " + LogInfo.COLUMN.MODEL + " = ? AND " + LogInfo.COLUMN.ACTION_DATE + " >= ? ", new String[] { _uuid, String.valueOf(_actionType.ordinal()), String.valueOf(_modelType.ordinal()), _time }, null); if (cursor == null) { return new ArrayList<>(); } if (cursor.getCount() == 0) { cursor.close(); return new ArrayList<>(); } List<LogInfo> list = new ArrayList<>(cursor.getCount()); cursor.moveToFirst(); try { do { int id = cursor.getInt(cursor.getColumnIndex(LogInfo.COLUMN.ID)); String uuid = cursor.getString(cursor.getColumnIndex(LogInfo.COLUMN.ITEM_UUID)); int action = cursor.getInt(cursor.getColumnIndex(LogInfo.COLUMN.ACTION)); eActionType actionType = eActionType.getTypeById(action); int model = cursor.getInt(cursor.getColumnIndex(LogInfo.COLUMN.MODEL)); eModelType modelType = eModelType.getTypeId(model); String date = cursor.getString(cursor.getColumnIndex(LogInfo.COLUMN.ACTION_DATE)); list.add(new LogInfo(id, uuid, actionType, modelType, ISO8601Utils.parse(date, new ParsePosition(0)))); } while (cursor.moveToNext()); } catch (ParseException e) { e.printStackTrace(); return new ArrayList<>(); } finally { cursor.close(); } return list; }
From source file:uni.projecte.dataLayer.CitationManager.Xflora.XfloraExporter.java
@Override public void writeCitationDate(String dateString) { SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); SimpleDateFormat outputFormatter = new SimpleDateFormat("dd/MM/yyyy"); try {//from w w w .j ava 2s .c om Date date = inFormat.parse(dateString); String XfloraDate = outputFormatter.format(date); addFieldValue(XFloraParser.getDateCod(XfloraDate)); } catch (ParseException e) { e.printStackTrace(); } }
From source file:com.ewcms.component.query.dao.QueryDAO.java
@Override public List<Article> findArtilce(String title, Integer channelId, String beginDate, String endDate, Boolean isContent) {//from www .j ava 2 s .co m Boolean isIf = false; String sql = "Select r.id, a.title, a.author, a.published, a.url, s.name From content_article_main As r Left Join site_channel As s On r.channel_id = s.id Left Join content_article As a On r.article_id = a.id Left Join content_content As c On a.id=c.article_id Where @isIf@ And a.status='RELEASE' "; List<Object> params = new ArrayList<Object>(); if (title != null && !title.trim().equals("")) { isIf = true; sql += " And a.title Like ? "; params.add("%" + title + "%"); } if (isContent != null && isContent) { isIf = true; sql += " And c.detail Like ? "; params.add("%" + title + "%"); } if (channelId != null && channelId.longValue() > 0) { isIf = true; sql += " And s.id=? "; params.add(channelId); } if (beginDate != null && !beginDate.trim().equals("")) { Date _beginDate; try { _beginDate = DATE_FORMAT.parse(beginDate); sql += " And a.published >= ?"; isIf = true; params.add(_beginDate); } catch (ParseException e) { e.printStackTrace(); } } if (endDate != null && !endDate.trim().equals("")) { try { Date _endDate = DATE_FORMAT.parse(endDate); sql += " And a.published <= ? "; isIf = true; params.add(_endDate); } catch (ParseException e) { e.printStackTrace(); } } if (isIf) { sql = sql.replace("@isIf@", "1=1"); } else { sql = sql.replace("@isIf@", "1<>1"); } sql += " Order By a.published Desc"; return jdbcTemplate.query(sql, params.toArray(), new RowMapper<Article>() { @Override public Article mapRow(ResultSet rs, int rowNum) throws SQLException { return articleRowMapper(rs); } }); }