Java Code Examples for java.text.ParseException.getMessage()

The following are Jave code examples for showing how to use getMessage() of the java.text.ParseException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: oscm   File: CurrencyConverter.java   View Source Code Vote up 6 votes
/**
 * Conversion to server representation, so converting currency to internal
 * integer with cents format. Prior to the conversion the input value is
 * validated.
 * 
 * @param context
 *            JSF context.
 * @param component
 *            Component which value will be processed.
 * @param value
 *            Value.
 */
public Object getAsObject(FacesContext context, UIComponent component,
        String value) {
    final PriceConverter converter = getConverter(context);

    try {
        return converter.parse(value);
    } catch (ParseException e) {
        String msg = e.getMessage();
        if (msg != null
                && msg.equals("ERROR_PRICEMODEL_INVALID_FRACTIONAL_PART")) {
            throw new ConverterException(JSFUtils.getFacesMessage(
                    component, context,
                    BaseBean.ERROR_PRICEMODEL_INVALID_FRACTIONAL_PART));
        }
        throw new ConverterException(JSFUtils.getFacesMessage(component,
                context, BaseBean.ERROR_PRICEMODEL_INPUT));
    }
}
 
Example 2
Project: unitimes   File: EventDateMappings.java   View Source Code Vote up 6 votes
protected void update(EventDateMapping mapping, Record record, SessionContext context, Session hibSession) {
	try {
		if (mapping == null) return;
		Formats.Format<Date> dateFormat = Formats.getDateFormat(Formats.Pattern.DATE_EVENT);
		if (ToolBox.equals(dateFormat.format(mapping.getClassDate()), record.getField(0)) &&
				ToolBox.equals(dateFormat.format(mapping.getEventDate()), record.getField(1)) &&
				ToolBox.equals(mapping.getNote(), record.getField(2))) return;
		mapping.setClassDate(dateFormat.parse(record.getField(0)));
		mapping.setEventDate(dateFormat.parse(record.getField(1)));
		mapping.setNote(record.getField(2));
		hibSession.saveOrUpdate(mapping);
		ChangeLog.addChange(hibSession,
				context,
				mapping,
				dateFormat.format(mapping.getClassDate()) + " &rarr; " + dateFormat.format(mapping.getEventDate()),
				Source.SIMPLE_EDIT, 
				Operation.UPDATE,
				null,
				null);
	} catch (ParseException e) {
		throw new GwtRpcException(e.getMessage(), e);
	}
}
 
Example 3
Project: EatDubbo   File: ConditionRouter.java   View Source Code Vote up 6 votes
public ConditionRouter(URL url) {
    this.url = url;
    this.priority = url.getParameter(Constants.PRIORITY_KEY, 0);
    this.force = url.getParameter(Constants.FORCE_KEY, false);
    try {
        String rule = url.getParameterAndDecoded(Constants.RULE_KEY);
        if (rule == null || rule.trim().length() == 0) {
            throw new IllegalArgumentException("Illegal route rule!");
        }
        rule = rule.replace("consumer.", "").replace("provider.", "");
        int i = rule.indexOf("=>");
        String whenRule = i < 0 ? null : rule.substring(0, i).trim();
        String thenRule = i < 0 ? rule.trim() : rule.substring(i + 2).trim();
        Map<String, MatchPair> when = StringUtils.isBlank(whenRule) || "true".equals(whenRule) ? new HashMap<String, MatchPair>() : parseRule(whenRule);
        Map<String, MatchPair> then = StringUtils.isBlank(thenRule) || "false".equals(thenRule) ? null : parseRule(thenRule);
        // NOTE: When条件是允许为空的,外部业务来保证类似的约束条件
        this.whenCondition = when;
        this.thenCondition = then;
    } catch (ParseException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
Example 4
Project: dubbox-hystrix   File: ConditionRouter.java   View Source Code Vote up 6 votes
public ConditionRouter(URL url) {
    this.url = url;
    this.priority = url.getParameter(Constants.PRIORITY_KEY, 0);
    this.force = url.getParameter(Constants.FORCE_KEY, false);
    try {
        String rule = url.getParameterAndDecoded(Constants.RULE_KEY);
        if (rule == null || rule.trim().length() == 0) {
            throw new IllegalArgumentException("Illegal route rule!");
        }
        rule = rule.replace("consumer.", "").replace("provider.", "");
        int i = rule.indexOf("=>");
        String whenRule = i < 0 ? null : rule.substring(0, i).trim();
        String thenRule = i < 0 ? rule.trim() : rule.substring(i + 2).trim();
        Map<String, MatchPair> when = StringUtils.isBlank(whenRule) || "true".equals(whenRule) ? new HashMap<String, MatchPair>() : parseRule(whenRule);
        Map<String, MatchPair> then = StringUtils.isBlank(thenRule) || "false".equals(thenRule) ? null : parseRule(thenRule);
        // NOTE: When条件是允许为空的,外部业务来保证类似的约束条件
        this.whenCondition = when;
        this.thenCondition = then;
    } catch (ParseException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
Example 5
Project: BiglyBT   File: DERUTCTime.java   View Source Code Vote up 5 votes
/**
 * The correct format for this is YYMMDDHHMMSSZ (it used to be that seconds were
 * never encoded. When you're creating one of these objects from scratch, that's
 * what you want to use, otherwise we'll try to deal with whatever gets read from
 * the input stream... (this is why the input format is different from the getTime()
 * method output).
 * <p>
 *
 * @param time the time string.
 */
public DERUTCTime(
    String  time)
{
    this.time = time;
    try
    {
        this.getDate();
    }
    catch (ParseException e)
    {
        throw new IllegalArgumentException("invalid date string: " + e.getMessage());
    }
}
 
Example 6
Project: keepass2android   File: DERGeneralizedTime.java   View Source Code Vote up 5 votes
/**
 * The correct format for this is YYYYMMDDHHMMSS[.f]Z, or without the Z
 * for local time, or Z+-HHMM on the end, for difference between local
 * time and UTC time. The fractional second amount f must consist of at
 * least one number with trailing zeroes removed.
 *
 * @param time the time string.
 * @exception IllegalArgumentException if String is an illegal format.
 */
public DERGeneralizedTime(
    String  time)
{
    this.time = time;
    try
    {
        this.getDate();
    }
    catch (ParseException e)
    {
        throw new IllegalArgumentException("invalid date string: " + e.getMessage());
    }
}
 
Example 7
Project: keepass2android   File: DERUTCTime.java   View Source Code Vote up 5 votes
/**
 * The correct format for this is YYMMDDHHMMSSZ (it used to be that seconds were
 * never encoded. When you're creating one of these objects from scratch, that's
 * what you want to use, otherwise we'll try to deal with whatever gets read from
 * the input stream... (this is why the input format is different from the getTime()
 * method output).
 * <p>
 *
 * @param time the time string.
 */
public DERUTCTime(
    String  time)
{
    this.time = time;
    try
    {
        this.getDate();
    }
    catch (ParseException e)
    {
        throw new IllegalArgumentException("invalid date string: " + e.getMessage());
    }
}
 
Example 8
Project: stroom-query   File: CompiledFields.java   View Source Code Vote up 5 votes
public CompiledFields(final List<Field> fields,
                      final FieldIndexMap fieldIndexMap, final Map<String, String> paramMap) {
    if (null != fields) {
        compiledFields = new ArrayList<>(fields.size());

        final ExpressionParser expressionParser = new ExpressionParser(new FunctionFactory(), new ParamFactory());
        for (final Field field : fields) {
            // Create compiled field.
            int groupDepth = -1;
            if (field.getGroup() != null) {
                groupDepth = field.getGroup();
            }
            Expression expression = null;
            if (fieldIndexMap != null && field.getExpression() != null && field.getExpression().trim().length() > 0) {
                try {
                    expression = expressionParser.parse(fieldIndexMap, field.getExpression());
                } catch (final ParseException e) {
                    throw new RuntimeException(e.getMessage(), e);
                }
            }

            CompiledFilter filter = null;
            if (field.getFilter() != null) {
                filter = new CompiledFilter(field.getFilter(), paramMap);
            }

            final CompiledField compiledField = new CompiledField(field, groupDepth, expression, filter);

            // Only include this field if it is used for display, grouping,
            // sorting.
            compiledFields.add(compiledField);
        }
    } else {
        compiledFields = Collections.emptyList();
    }
}
 
Example 9
Project: dhus-core   File: Synchronizer.java   View Source Code Vote up 5 votes
/**
 * Creates an new Synchronizer from the given ODataEntry.
 * 
 * @param odata_entry created by a POST request on the OData interface.
 * @throws ODataException if the given entry is malformed.
 */
public Synchronizer (ODataEntry odata_entry) throws ODataException
{
   Map<String, Object> props = odata_entry.getProperties ();

   String label = (String) props.get(SynchronizerEntitySet.LABEL);
   String schedule = (String) props.get(SynchronizerEntitySet.SCHEDULE);
   String request = (String) props.get(SynchronizerEntitySet.REQUEST);
   String service_url = (String) props.get(SynchronizerEntitySet.SERVICE_URL);

   if (schedule == null || schedule.isEmpty () || service_url == null ||
      service_url.isEmpty ())
   {
      throw new IncompleteDocException();
   }

   if (request != null && !request.equals ("start") &&
      !request.equals ("stop"))
   {
      throw new InvalidValueException(SynchronizerEntitySet.REQUEST, request);
   }

   try
   {
      this.syncConf =
         SYNCHRONIZER_SERVICE.createSynchronizer (label,
            "ODataProductSynchronizer", schedule);
      updateFromEntry (odata_entry);
   }
   catch (ParseException e)
   {
      throw new ExpectedException(e.getMessage());
   }
}
 
Example 10
Project: dubbo2   File: GenericJSONConverter.java   View Source Code Vote up 5 votes
public Object decode(Object jv) throws IOException
{
	if( jv instanceof String ) {
		try {
			return new SimpleDateFormat(DATE_FORMAT).parse((String) jv);
		} catch (ParseException e) {
			throw new IllegalArgumentException(e.getMessage(), e);
		}
	}
	if( jv instanceof Number ) 
		return new Date(((Number)jv).longValue());
	return (Date)null;
}
 
Example 11
Project: lams   File: JTidyPrintWriter.java   View Source Code Vote up 5 votes
private int parseInteger( String integer ) {
    try {
        return INTEGER_FORMAT.parse( integer ).intValue();
    } catch (ParseException e) {
        throw new NumberFormatException( "Unable to parse integer [int: " + integer + ", error: " + e.getMessage() );
    }
}
 
Example 12
Project: ipack   File: SingleResp.java   View Source Code Vote up 5 votes
public Date getThisUpdate()
{
    try
    {
        return resp.getThisUpdate().getDate();
    }
    catch (ParseException e)
    {
        throw new IllegalStateException("ParseException: " + e.getMessage());
    }
}
 
Example 13
Project: BiglyBT   File: DERGeneralizedTime.java   View Source Code Vote up 5 votes
/**
 * The correct format for this is YYYYMMDDHHMMSS[.f]Z, or without the Z
 * for local time, or Z+-HHMM on the end, for difference between local
 * time and UTC time. The fractional second amount f must consist of at
 * least one number with trailing zeroes removed.
 *
 * @param time the time string.
 * @exception IllegalArgumentException if String is an illegal format.
 */
public DERGeneralizedTime(
    String  time)
{
    this.time = time;
    try
    {
        this.getDate();
    }
    catch (ParseException e)
    {
        throw new IllegalArgumentException("invalid date string: " + e.getMessage());
    }
}
 
Example 14
Project: openjdk-jdk10   File: JstatResults.java   View Source Code Vote up 5 votes
/**
 * Gets an integer result from the column labeled 'name'
 *
 * @param name - name of the column
 * @return the result
 */
public int getIntValue(String name) {
    int valueNdx = new StringOfValues(getStdoutLine(0)).getIndex(name);
    try {
        return NumberFormat.getInstance().parse(new StringOfValues(getStdoutLine(1)).getValue(valueNdx)).intValue();
    } catch (ParseException e) {
        throw new NumberFormatException(e.getMessage());
    }
}
 
Example 15
Project: zookeeper-sandbox   File: GenericJSONConverter.java   View Source Code Vote up 5 votes
public Object decode(Object jv) throws IOException
{
	if( jv instanceof String ) {
		try {
			return new SimpleDateFormat(DATE_FORMAT).parse((String) jv);
		} catch (ParseException e) {
			throw new IllegalArgumentException(e.getMessage(), e);
		}
	}
	if( jv instanceof Number ) 
		return new Date(((Number)jv).longValue());
	return (Date)null;
}
 
Example 16
Project: cyberduck   File: AbstractDateFormatter.java   View Source Code Vote up 5 votes
@Override
public Date parse(final String input) throws InvalidDateException {
    if(StringUtils.isBlank(input)) {
        throw new InvalidDateException();
    }
    synchronized(format) {
        try {
            return format.parse(input);
        }
        catch(ParseException e) {
            throw new InvalidDateException(e.getMessage(), e);
        }
    }
}
 
Example 17
Project: SuitAgent   File: DateUtil.java   View Source Code Vote up 5 votes
/**
 * 日期比较,当baseDate大于compareDate时,返回TRUE,当小于等于时,返回false
 * @param format
 *            日期字符串格式
 * @param baseDate
 *            被比较的日期
 * @param compareDate
 *            比较日期
 * @return
 */
public static boolean after(String format, String baseDate,
                             String compareDate) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
    try {
        Date base = simpleDateFormat.parse(baseDate);
        Date compare = simpleDateFormat.parse(compareDate);

        return compare.after(base);
    } catch (ParseException e) {
        throw new RuntimeException(e.getMessage());
    }
}
 
Example 18
Project: springboot-training   File: DateUtil.java   View Source Code Vote up 5 votes
/**
 * 获取当天的最后一秒
 * 
 * @param timeZone
 *            时区
 * @return GMT时间对象
 */
public Date getTodayLastSecond(int timeZone) {
	// 当前的GMT时间
	Date now = getNow();

	// 获取本地的年月日
	String ymd = this.getDateFormat(timeZone).format(now);

	// 获取本地的当天的最后一秒,换算成GMT的时间对象
	try {
		return this.getDateTimeFormat(timeZone).parse(ymd + " 23:59:59");
	} catch (ParseException e) {
		throw new ZhhrUtilException(e.getMessage(), e);
	}
}
 
Example 19
Project: dhus-core   File: UserSynchronizer.java   View Source Code Vote up 5 votes
/**
 * Creates an new UserSynchronizer from the given ODataEntry.
 *
 * @param odata_entry created by a POST request on the OData interface.
 * @throws ODataException if the given entry is malformed.
 */
public UserSynchronizer(ODataEntry odata_entry) throws ODataException
{
   Map<String, Object> props = odata_entry.getProperties();

   String label       = (String) props.get(LABEL);
   String schedule    = (String) props.get(SCHEDULE);
   String request     = (String) props.get(REQUEST);
   String service_url = (String) props.get(SERVICE_URL);

   if (schedule == null || schedule.isEmpty() || service_url == null || service_url.isEmpty())
   {
      throw new IncompleteDocException();
   }

   if (request != null && !request.equals("start") && !request.equals("stop"))
   {
      throw new InvalidValueException(REQUEST, request);
   }

   try
   {
      this.syncConf = SYNC_SERVICE.createSynchronizer(label, "ODataUserSynchronizer", schedule);
      updateFromEntry(odata_entry);
   }
   catch (ParseException e)
   {
      throw new ExpectedException(e.getMessage());
   }
}
 
Example 20
Project: sentry   File: CronExpressionDescriptor.java   View Source Code Vote up 4 votes
public static String getDescription(DescriptionTypeEnum type, String expression, Options options, Locale locale) throws ParseException {
    I18nMessages.setCurrentLocale(locale);
    String[] expressionParts;
    String description = "";
    try {
        expressionParts = ExpressionParser.parse(expression, options);
        switch (type) {
            case FULL:
                description = getFullDescription(expressionParts, options);
                break;
            case TIMEOFDAY:
                description = getTimeOfDayDescription(expressionParts);
                break;
            case HOURS:
                description = getHoursDescription(expressionParts);
                break;
            case MINUTES:
                description = getMinutesDescription(expressionParts);
                break;
            case SECONDS:
                description = getSecondsDescription(expressionParts);
                break;
            case DAYOFMONTH:
                description = getDayOfMonthDescription(expressionParts);
                break;
            case MONTH:
                description = getMonthDescription(expressionParts);
                break;
            case DAYOFWEEK:
                description = getDayOfWeekDescription(expressionParts, options);
                break;
            case YEAR:
                description = getYearDescription(expressionParts, options);
                break;
            default:
                description = getSecondsDescription(expressionParts);
                break;
        }
    } catch (ParseException e) {
        if (!options.isThrowExceptionOnParseError()) {
            description = e.getMessage();
            LOG.debug("Exception parsing expression.", e);
        } else {
            LOG.error("Exception parsing expression.", e);
            throw e;
        }
    }
    return description;
}