List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:com.silverpeas.comment.dao.jdbc.JDBCCommentRequester.java
/** * Gets the comment identified by the specified identifier. * @param con the connection to use for getting the comment. * @param pk the identifier of the comment in the data source. * @return the comment or null if no such comment is found. * @throws SQLException if an error occurs during the comment fetching. *///w w w .j a v a 2s . co m public Comment getComment(Connection con, CommentPK pk) throws SQLException { String select_query = "SELECT commentOwnerId, commentCreationDate, commentModificationDate, " + "commentComment, resourceType, resourceId, instanceId FROM sb_comment_comment WHERE commentId = ?"; PreparedStatement prep_stmt = null; ResultSet rs = null; try { prep_stmt = con.prepareStatement(select_query); prep_stmt.setInt(1, Integer.parseInt(pk.getId())); rs = prep_stmt.executeQuery(); if (rs.next()) { pk.setComponentName(rs.getString("instanceId")); WAPrimaryKey father_id = new CommentPK(rs.getString("resourceId")); try { Date modifDate = null; String sqlModifDate = rs.getString("commentModificationDate"); if (StringUtil.isDefined(sqlModifDate)) { modifDate = parseDate(rs.getString("commentModificationDate")); } return new Comment(pk, rs.getString("resourceType"), father_id, rs.getInt("commentOwnerId"), "", rs.getString("commentComment"), parseDate(rs.getString("commentCreationDate")), modifDate); } catch (ParseException ex) { throw new SQLException(ex.getMessage(), ex); } } return null; } finally { DBUtil.close(rs, prep_stmt); } }
From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJDoubleEditor.java
public Double getDoubleValue() { final String S_ProcName = "getDoubleValue"; Double retval;//from w ww . ja v a2s . c o m String text = getText(); if ((text == null) || (text.length() <= 0)) { retval = null; } else { if (!isEditValid()) { throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName, "Field is not valid"); } try { commitEdit(); } catch (ParseException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Field is not valid - " + e.getMessage(), e); } Object obj = getValue(); if (obj == null) { retval = null; } else if (obj instanceof Float) { Float f = (Float) obj; Double v = new Double(f.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Double) { Double v = (Double) obj; if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Short) { Short s = (Short) obj; Double v = new Double(s.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Integer) { Integer i = (Integer) obj; Double v = new Double(i.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Long) { Long l = (Long) obj; Double v = new Double(l.doubleValue()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof BigDecimal) { BigDecimal b = (BigDecimal) obj; Double v = new Double(b.toString()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else if (obj instanceof Number) { Number n = (Number) obj; Double v = new Double(n.toString()); if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) { throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0, "EditedValue", v, minValue, maxValue); } retval = v; } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName, "EditedValue", obj, "Short, Integer, Long, BigDecimal or Number"); } } return (retval); }
From source file:TextInputDemo.java
protected MaskFormatter createFormatter(String s) { MaskFormatter formatter = null; try {//from ww w. ja v a2 s. c o m formatter = new MaskFormatter(s); } catch (java.text.ParseException exc) { System.err.println("formatter is bad: " + exc.getMessage()); System.exit(-1); } return formatter; }
From source file:net.solarnetwork.node.backup.FileSystemBackupService.java
private SimpleBackup createBackupForFile(File f, SimpleDateFormat sdf) { Matcher m = ARCHIVE_NAME_PAT.matcher(f.getName()); if (m.matches()) { try {/*w w w. j a v a 2 s . co m*/ Date d = sdf.parse(m.group(1)); return new SimpleBackup(d, m.group(1), f.length(), true); } catch (ParseException e) { log.error("Error parsing date from archive " + f.getName() + ": " + e.getMessage()); } } return null; }
From source file:com.haulmont.cuba.web.gui.components.WebTimeField.java
@SuppressWarnings("unchecked") @Override/*from w w w .j a v a2s . c o m*/ public Date getValue() { Object value = super.getValue(); if (value instanceof String) { try { SimpleDateFormat sdf = new SimpleDateFormat(timeFormat); return sdf.parse((String) value); } catch (ParseException e) { LoggerFactory.getLogger(WebTimeField.class).debug("Unable to parse value of component {}\n{}", getId(), e.getMessage()); return null; } } else { return (Date) value; } }
From source file:com.silverpeas.comment.dao.jdbc.JDBCCommentRequester.java
public List<Comment> getAllComments(Connection con, String resourceType, WAPrimaryKey foreign_pk) throws SQLException { final List<String> params = new ArrayList<String>(); final StringBuilder select_query = new StringBuilder(); select_query.append("SELECT commentId, commentOwnerId, commentCreationDate, commentModificationDate, "); select_query.append("commentComment, resourceType, resourceId, instanceId FROM sb_comment_comment"); performQueryAndParams(select_query, params, resourceType, foreign_pk); select_query.append("ORDER BY commentCreationDate DESC, commentId DESC"); PreparedStatement prep_stmt = null; ResultSet rs = null;/* www . ja v a 2s .com*/ List<Comment> comments = new ArrayList<Comment>(INITIAL_CAPACITY); try { prep_stmt = con.prepareStatement(select_query.toString()); int indexParam = 1; for (String param : params) { prep_stmt.setString(indexParam++, param); } rs = prep_stmt.executeQuery(); CommentPK pk; Comment cmt = null; while (rs.next()) { pk = new CommentPK(String.valueOf(rs.getInt("commentId"))); pk.setComponentName(rs.getString("instanceId")); WAPrimaryKey father_id = new CommentPK(rs.getString("resourceId")); try { cmt = new Comment(pk, rs.getString("resourceType"), father_id, rs.getInt("commentOwnerId"), "", rs.getString("commentComment"), parseDate(rs.getString("commentCreationDate")), parseDate(rs.getString("commentModificationDate"))); } catch (ParseException ex) { throw new SQLException(ex.getMessage(), ex); } comments.add(cmt); } } finally { DBUtil.close(rs, prep_stmt); } return comments; }
From source file:com.silverpeas.comment.dao.jdbc.JDBCCommentRequester.java
public List<Comment> getLastComments(Connection con, String instanceId, int count) throws SQLException { final List<String> params = new ArrayList<String>(); String query = "SELECT commentId, commentOwnerId, commentCreationDate, " + "commentModificationDate, commentComment, resourceType, resourceId, instanceId " + "FROM sb_comment_comment where instanceId = ? ORDER BY commentCreationDate DESC, " + "commentId DESC"; if (count > 0) { query += " LIMIT ?"; }//from w ww . j av a 2 s . co m PreparedStatement stmt = null; ResultSet rs = null; List<Comment> comments = new ArrayList<Comment>(count); try { stmt = con.prepareStatement(query); stmt.setString(1, instanceId); if (count > 0) { stmt.setInt(2, count); } rs = stmt.executeQuery(); while (rs.next()) { CommentPK pk = new CommentPK(String.valueOf(rs.getInt("commentId"))); pk.setComponentName(rs.getString("instanceId")); WAPrimaryKey resourceId = new CommentPK(rs.getString("resourceId")); try { Comment cmt = new Comment(pk, rs.getString("resourceType"), resourceId, rs.getInt("commentOwnerId"), "", rs.getString("commentComment"), parseDate(rs.getString("commentCreationDate")), parseDate(rs.getString("commentModificationDate"))); comments.add(cmt); } catch (ParseException ex) { throw new SQLException(ex.getMessage(), ex); } } } finally { DBUtil.close(rs, stmt); } return comments; }
From source file:com.clustercontrol.jobmanagement.factory.JobPlanSchedule.java
/** * ??// ww w .j ava 2 s . co m * MAX_YEAR???????????null? * * @param calendarId * @return */ public Long getNextPlan() { // ??next()??????????firstFlg while (firstFlg || next()) { // ???firstFlgfalse?? if (firstFlg) { firstFlg = false; } SelectCalendar select = new SelectCalendar(); m_log.debug(year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); sdf.setTimeZone(HinemosTime.getTimeZone()); Date date = null; try { date = sdf.parse(year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second); } catch (ParseException e1) { m_log.warn("ParseException : " + e1.getMessage(), e1); return null; } m_log.debug("Date : " + date); if (calendarId == null) { if (date.getTime() > startTime) { return date.getTime(); } } else { CalendarInfo calInfo = null; try { calInfo = select.getCalendarFull(calendarId); if (calInfo.getValidTimeTo() < date.getTime()) { return null; } if (CalendarUtil.isRun(calInfo, date) && isDate(year, month, day)) { if (date.getTime() > startTime) { return date.getTime(); } } } catch (CalendarNotFound e) { m_log.warn("getNextPlan : " + e.getClass().getName() + ", " + e.getMessage()); } catch (InvalidRole e) { m_log.warn("getNextPlan : " + e.getClass().getName() + ", " + e.getMessage()); } } } return null; }
From source file:de.highbyte_le.weberknecht.request.RequestWrapper.java
Date parseDate(String value) { Date date = null;// ww w .j ava 2 s.c om if (value != null && value.length() > 0) { try { SimpleDateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd"); date = isoDateFormat.parse(value); } catch (ParseException e) { logger.warn("getParameterAsDate() - exception while parsing date: " + e.getMessage()); } } return date; }