Package java.text

Examples of java.text.ParseException


              throw e;
            }
           
          }
        }
        throw new ParseException("Failed to parse date="+date, 0);
    }
View Full Code Here


  private static Object parse(Format format, String value) throws ParseException {
    ParsePosition pos = new ParsePosition(0);
    Object result = format.parseObject(value, pos);
    if (pos.getIndex() < value.length())
      throw new ParseException("Cannot parse " + value + " (garbage suffix)!", pos.getIndex());
    return result;
  }
View Full Code Here

    if ("true".equals(value)) {
      return Boolean.TRUE;
    } else if ("false".equals(value)) {
      return Boolean.FALSE;
    } else {
      throw new ParseException("Cannot parse '" + value + "' as boolean", 0);
    }
  }
View Full Code Here

    }
  }

  private static Character parseCharacter(String value) throws ParseException {
    if (value.length() != 1) {
      throw new ParseException("Cannot parse '" + value + "' as character", value.length());
    }
    return new Character(value.charAt(0));
  }
View Full Code Here

    } else if (type == Short.class) {
      return Short.valueOf(value);
    } else if (type == String.class) {
      return value;
    }
    throw new ParseException("Cannot parse type " + type, 0);
  }
View Full Code Here

    Number d = (Number) super.parse(value);
    if (d == null || d instanceof Short)
      return d;
    long l = d.longValue();
    if (l < Short.MIN_VALUE || l > Short.MAX_VALUE)
      throw new ParseException("", 0);
    return new Short(d.shortValue());
  }
View Full Code Here

  public Object parse(HttpServletRequest request, String key) throws ParseException {
    ListModel listModel = getListModel(request);
    if (!listModel.containsKey(key)) {
      if (key == null || key.length() == 0) {
        if (listModel.getKey(null) != null) {
          throw new ParseException("Cannot parse empty/null input", 0);
        }
        return null;
      }
      throw new ParseException("Unknown list model key", 0);
    }
    return listModel.getValue(key);
  }
View Full Code Here

      return null;
    else {
      ParsePosition pos = new ParsePosition(0);
      Object result = getFormat().parseObject(value, pos);
      if (pos.getIndex() < value.length())
        throw new ParseException("Found garbage suffix!", pos.getIndex());
      return result;
    }
  }
View Full Code Here

    if (value == null || value.length() == 0)
      return null;
    try {
      return new BigInteger(value, radix);
    } catch (Exception e) {
      throw new ParseException("", 0);
    }
  }
View Full Code Here

        String[] properties = parameterList.split(",");
        for (int i = 0; i < properties.length; i++) {
            String n = properties[i];
            int idx = n.indexOf('=');
            if (idx == -1) {
                throw new ParseException("Parameter list in incorrect format. [<name>=<value>[,<name>=<value>] ..]", 0);
            }
            String v = n.substring(idx + 1);
            n = n.substring(0, idx);
            p.setProperty(n, v);
        }
View Full Code Here

TOP

Related Classes of java.text.ParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.