List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:Main.java
MaskFormatter createFormatter(String format) { MaskFormatter formatter = null; try {/*from w w w . j a va 2 s .co m*/ formatter = new MaskFormatter(format); formatter.setPlaceholderCharacter('.'/*or '0' etc*/); formatter.setAllowsInvalid(false); // if needed formatter.setOverwriteMode(true); // if needed } catch (java.text.ParseException exc) { System.err.println("formatter is bad: " + exc.getMessage()); } return formatter; }
From source file:org.exoplatform.services.jcr.impl.core.query.sql.JCRSQLQueryBuilder.java
/** * Creates a <code>QueryNode</code> tree from a SQL <code>statement</code> * using the passed query node <code>factory</code>. * * @param statement the SQL statement./*ww w. j a v a2s .c o m*/ * @param resolver the namespace resolver to use. * @return the <code>QueryNode</code> tree. * @throws InvalidQueryException if <code>statement</code> is malformed. */ public static QueryRootNode createQuery(String statement, LocationFactory resolver, QueryNodeFactory factory) throws InvalidQueryException { try { // get parser JCRSQLParser parser; synchronized (parsers) { parser = (JCRSQLParser) parsers.get(resolver); if (parser == null) { parser = new JCRSQLParser(new StringReader(statement)); //parser.setNameResolver(resolver); parser.setLocationfactory(resolver); parsers.put(resolver, parser); } } JCRSQLQueryBuilder builder; // guard against concurrent use within same session synchronized (parser) { parser.ReInit(new StringReader(statement)); builder = new JCRSQLQueryBuilder(parser.Query(), resolver, factory); } return builder.getRootNode(); } catch (ParseException e) { throw new InvalidQueryException(e.getMessage()); } catch (IllegalArgumentException e) { throw new InvalidQueryException(e.getMessage()); } catch (Throwable t) //NOSONAR { log.error(t.getLocalizedMessage(), t); // javacc parser may also throw an error in some cases throw new InvalidQueryException(t.getMessage(), t); } }
From source file:Main.java
private MaskFormatter createFormatter(String s) { MaskFormatter formatter = null; try {/*w w w. j a v a 2s. co m*/ formatter = new MaskFormatter(s); } catch (java.text.ParseException exc) { System.err.println("formatter is bad: " + exc.getMessage()); } return formatter; }
From source file:org.apache.jackrabbit.spi.commons.query.sql.JCRSQLQueryBuilder.java
/** * Creates a <code>QueryNode</code> tree from a SQL <code>statement</code> * using the passed query node <code>factory</code>. * * @param statement the SQL statement./* w w w . j a va 2 s. c o m*/ * @param resolver the namespace resolver to use. * @return the <code>QueryNode</code> tree. * @throws InvalidQueryException if <code>statement</code> is malformed. */ public static QueryRootNode createQuery(String statement, NameResolver resolver, QueryNodeFactory factory) throws InvalidQueryException { try { // get parser JCRSQLParser parser; synchronized (parsers) { parser = (JCRSQLParser) parsers.get(resolver); if (parser == null) { parser = new JCRSQLParser(new StringReader(statement)); parser.setNameResolver(resolver); parsers.put(resolver, parser); } } JCRSQLQueryBuilder builder; // guard against concurrent use within same session synchronized (parser) { parser.ReInit(new StringReader(statement)); builder = new JCRSQLQueryBuilder(parser.Query(), resolver, factory); } return builder.getRootNode(); } catch (ParseException e) { throw new InvalidQueryException(e.getMessage()); } catch (IllegalArgumentException e) { throw new InvalidQueryException(e.getMessage()); } catch (Throwable t) { // javacc parser may also throw an error in some cases throw new InvalidQueryException(t.getMessage()); } }
From source file:org.eclipse.winery.repository.backend.BackendUtils.java
/** * @return true if given fileDate is newer then the modified date (or * modified is null)//from w ww . j a va 2s.co m */ public static boolean isFileNewerThanModifiedDate(long millis, String modified) { if (modified == null) { return true; } Date modifiedDate = null; assert (Locale.getDefault() == Locale.ENGLISH); try { modifiedDate = DateUtils.parseDate(modified, org.apache.http.impl.cookie.DateUtils.DEFAULT_PATTERNS); } catch (ParseException e) { BackendUtils.logger.error(e.getMessage(), e); } if (modifiedDate != null) { // modifiedDate does not carry milliseconds, but fileDate does // therefore we have to do a range-based comparison if ((millis - modifiedDate.getTime()) < DateUtils.MILLIS_PER_SECOND) { return false; } } return true; }
From source file:com.microsoft.sqlserver.testframework.sqlType.SqlDateTime2.java
public SqlDateTime2() { super("datetime2", JDBCType.TIMESTAMP, null, null); try {/*from w w w.j a v a2 s . c o m*/ minvalue = new Timestamp(dateFormat.parse((String) SqlTypeValue.DATETIME2.minValue).getTime()); maxvalue = new Timestamp(dateFormat.parse((String) SqlTypeValue.DATETIME2.maxValue).getTime()); } catch (ParseException ex) { fail(ex.getMessage()); } this.precision = 7; this.variableLengthType = VariableLengthType.Precision; generatePrecision(); formatter = new DateTimeFormatterBuilder().appendPattern(basePattern) .appendFraction(ChronoField.NANO_OF_SECOND, 0, this.precision, true).toFormatter(); }
From source file:com.microsoft.sqlserver.testframework.sqlType.SqlTime.java
public SqlTime() { super("time", JDBCType.TIME, null, null); type = java.sql.Time.class; try {/*from w w w . j a va 2s. c om*/ minvalue = new Time(dateFormat.parse((String) SqlTypeValue.TIME.minValue).getTime()); maxvalue = new Time(dateFormat.parse((String) SqlTypeValue.TIME.maxValue).getTime()); } catch (ParseException ex) { fail(ex.getMessage()); } this.precision = 7; this.variableLengthType = VariableLengthType.Precision; generatePrecision(); formatter = new DateTimeFormatterBuilder().appendPattern(basePattern) .appendFraction(ChronoField.NANO_OF_SECOND, 0, this.precision, true).toFormatter(); }
From source file:com.stratelia.webactiv.util.DateUtil.java
/** * Parse the date in a language specific standard format. * @param string The String to convert in Date * @param language The current user's language * @return A Date representation of the String in the language specific format. * @throws java.text.ParseException if the input String is null, empty, or just in an incorrect * format.//from w w w . j a v a 2s.co m */ public static Date stringToDate(String string, String language) throws ParseException { SimpleDateFormat format = getDateInputFormat(language); try { return format.parse(string); } catch (ParseException e) { throw e; } catch (Exception e) { throw new ParseException(e.getMessage(), 0); } }
From source file:ch.cyberduck.core.date.AbstractDateFormatter.java
@Override public Date parse(final String input) throws InvalidDateException { if (StringUtils.isBlank(input)) { throw new InvalidDateException(); }/*from w w w . j ava 2 s. c o m*/ synchronized (format) { try { return format.parse(input); } catch (ParseException e) { throw new InvalidDateException(e.getMessage(), e); } } }
From source file:cz.zcu.kiv.eegdatabase.wui.components.table.TimestampConverter.java
@Override public Timestamp convertToObject(String value, Locale locale) { try {//from w w w.j ava 2 s . com long time = new SimpleDateFormat(getParsePattern()).parse(value).getTime(); return new Timestamp(time); } catch (ParseException e) { log.info(e.getMessage(), e); throw new ConversionException("Wrong Date Format: " + parsePattern); } }