Package java.text

Examples of java.text.ParsePosition


    DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
    if (dfs.getGroupingSeparator() == '\u00a0')
      value = value.replace(' ', '\u00a0');
        

    ParsePosition pp = new ParsePosition(0);
    Number num = (Number) fmt.parseObject(value,pp);

    if (pp.getIndex() != value.length())
    {
      Object label = ConverterUtils.getComponentLabel(component);
      Object[] params = {label, value, getPattern()};
      throw new ConverterException(
        getConvertMessage(context, component, value, params));
View Full Code Here


   */
  @Override
  public Object parseObject(
    String source) throws ParseException
  {
    ParsePosition status = new ParsePosition(0);
    Object result = parseObject(source, status);
   
    int index = status.getIndex();
    if (index == 0 ||
        (source != null && index < source.length()))
    {
        throw new ParseException("Format.parseObject(String) failed",
            status.getErrorIndex());
    }
    return result;
  }
View Full Code Here

   */
  @Override
  public Object parseObject(
    String source) throws ParseException
  {
    ParsePosition status = new ParsePosition(0);
    Object result = parseObject(source, status);
    int index = status.getIndex();
    if (index == 0 ||
        (source != null && index < source.length()))
    {
        throw new ParseException("Format.parseObject(String) failed",
            status.getErrorIndex());
    }
    return result;
  }
View Full Code Here

    if (s == null || s.equals(""))
      return new Nullable<Date>();
    else {
      SimpleDateFormat df = new SimpleDateFormat(
          "yyyy-MM-dd'T'HH:mm:ss'Z'");
      Date d = df.parse(s, new ParsePosition(0));
      if (d == null)
        throw new InvalidFormatException("Date not well formated");
      return new Nullable<Date>(d);
    }
  }
View Full Code Here

    }

    @Test
    public void testParseIgnoredWhitespace() {
        Vector2D expected = new Vector2D(1, 1);
        ParsePosition pos1 = new ParsePosition(0);
        String source1 = "{1;1}";
        Assert.assertEquals(expected, vector2DFormat.parse(source1, pos1));
        Assert.assertEquals(source1.length(), pos1.getIndex());
        ParsePosition pos2 = new ParsePosition(0);
        String source2 = " { 1 ; 1 } ";
        Assert.assertEquals(expected, vector2DFormat.parse(source2, pos2));
        Assert.assertEquals(source2.length() - 1, pos2.getIndex());
    }
View Full Code Here

        Assert.assertEquals(nf, cf.getFormat());
    }

    @Test
    public void testForgottenPrefix() {
        ParsePosition pos = new ParsePosition(0);
        Assert.assertNull(new Vector2DFormat().parse("1; 1}", pos));
        Assert.assertEquals(0, pos.getErrorIndex());
    }
View Full Code Here

        Assert.assertEquals(0, pos.getErrorIndex());
    }

    @Test
    public void testForgottenSeparator() {
        ParsePosition pos = new ParsePosition(0);
        Assert.assertNull(new Vector2DFormat().parse("{1 1}", pos));
        Assert.assertEquals(3, pos.getErrorIndex());
    }
View Full Code Here

        Assert.assertEquals(3, pos.getErrorIndex());
    }

    @Test
    public void testForgottenSuffix() {
        ParsePosition pos = new ParsePosition(0);
        Assert.assertNull(new Vector2DFormat().parse("{1; 1 ", pos));
        Assert.assertEquals(5, pos.getErrorIndex());
    }
View Full Code Here

    }

    @Test
    public void testParseIgnoredWhitespace() {
        Vector1D expected = new Vector1D(1);
        ParsePosition pos1 = new ParsePosition(0);
        String source1 = "{1}";
        Assert.assertEquals(expected, vector1DFormat.parse(source1, pos1));
        Assert.assertEquals(source1.length(), pos1.getIndex());
        ParsePosition pos2 = new ParsePosition(0);
        String source2 = " { 1 } ";
        Assert.assertEquals(expected, vector1DFormat.parse(source2, pos2));
        Assert.assertEquals(source2.length() - 1, pos2.getIndex());
    }
View Full Code Here

        Assert.assertEquals(nf, cf.getFormat());
    }

    @Test
    public void testForgottenPrefix() {
        ParsePosition pos = new ParsePosition(0);
        Assert.assertNull(new Vector1DFormat().parse("1}", pos));
        Assert.assertEquals(0, pos.getErrorIndex());
    }
View Full Code Here

TOP

Related Classes of java.text.ParsePosition

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.