Package java.text

Examples of java.text.ParsePosition


      reader.read(chars, 0, chars.length);
      reader.close();
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      format.setTimeZone(TimeZone.getTimeZone("GMT+0"));
      String utcStr = new String(chars, 0, 19);
      Date utcDate = format.parse(utcStr, new ParsePosition(0));
      assertTrue(utcDate.getTime() >= start - 1000 && utcDate.getTime() < end + 1000);
      String cstStr = new String(chars, 21, 19);
      format.setTimeZone(TimeZone.getTimeZone("GMT-6"));
      Date cstDate = format.parse(cstStr, new ParsePosition(0));
      assertFalse(cstStr.equals(utcStr));
      assertTrue(cstDate.getTime() >= start - 1000 && cstDate.getTime() < end + 1000);
    }
View Full Code Here


        if (prop != null) {
            updatedDate = new Date(prop);
        }
        final String msgProp = (String) msgProps.get(FieldName.DATE);
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
        final Date msgDate = sdf.parse(msgProp, new ParsePosition(0));
        if (updatedDate == null || msgDate.after(updatedDate)) {
            thrdProps.put(MessageFieldName.LAST_UPDATE, msgDate.getTime());
            resolver.commit();
        }
    }
View Full Code Here

    if (dfi == null) {
      dfi = new DateFormatInfo();
      // date format: 30-MAR-1987 14:22:36.87
      dfi.df = new SimpleDateFormat("dd-MMM-yyyy kk:mm:ss.SSS",Locale.ROOT);
      dfi.df.setLenient(true);
      dfi.pos = new ParsePosition(0);
      dateFormat.set(dfi);
    }
    return dfi;
  }
View Full Code Here

                assertEquals("TFTFFFFFFFFT", results);

                s = (DateSelector)getInstance();
                s.setDatetime("11/21/2001 4:55 AM");
                SimpleDateFormat formatter = new SimpleDateFormat();
                Date d = formatter.parse("11/21/2001 4:55 AM",new ParsePosition(0));

                long milliseconds = s.getMillis();
                s.setWhen(equal);
                results = selectionString(s);
                assertEquals("TTFFTFFFTTTT", results);
View Full Code Here

        // Need to build the pattern in a temporary string because
        // _applyPattern calls add() etc., which set pat to empty.
        boolean parsePositionWasNull = pos == null;
        if (parsePositionWasNull) {
            pos = new ParsePosition(0);
        }

        StringBuffer rebuiltPat = new StringBuffer();
        RuleCharacterIterator chars =
            new RuleCharacterIterator(pattern, symbols, pos);
View Full Code Here

     * @param symbols TODO
     */
    private void applyPropertyPattern(RuleCharacterIterator chars,
                                      StringBuffer rebuiltPat, SymbolTable symbols) {
        String pat = chars.lookahead();
        ParsePosition pos = new ParsePosition(0);
        applyPropertyPattern(pat, pos, symbols);
        if (pos.getIndex() == 0) {
            syntaxError(chars, "Invalid property pattern");
        }
        chars.jumpahead(pos.getIndex());
        rebuiltPat.append(pat.substring(0, pos.getIndex()));
    }
View Full Code Here

     * text can be parsed as an integer and that the integer is positive.
     */
    private class PositiveNumberVerifier extends InputVerifier {
        public boolean verify(JComponent input) {
            String text = getText();
            ParsePosition pos = new ParsePosition(0);
            IntegerFormat.parse(text, pos);
            int index = pos.getIndex();
            if ((index <= 0) || (index != text.length())) {
                return false;
            }
            try {
                Number number = IntegerFormat.parse(text);
View Full Code Here

    }

    /** {@inheritDoc} */
    @Override
    public Vector2D parse(final String source) throws MathParseException {
        ParsePosition parsePosition = new ParsePosition(0);
        Vector2D result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Vector2D.class);
        }
        return result;
    }
View Full Code Here

     * @throws MathParseException if the beginning of the specified string
     * cannot be parsed.
     */
    @Override
    public Vector3D parse(final String source) throws MathParseException {
        ParsePosition parsePosition = new ParsePosition(0);
        Vector3D result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source,
                                         parsePosition.getErrorIndex(),
                                         Vector3D.class);
        }
        return result;
    }
View Full Code Here

     * @exception MathParseException if the beginning of the specified string
     *            cannot be parsed.
     */
    @Override
    public Fraction parse(final String source) throws MathParseException {
        final ParsePosition parsePosition = new ParsePosition(0);
        final Fraction result = parse(source, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new MathParseException(source, parsePosition.getErrorIndex(), Fraction.class);
        }
        return result;
    }
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.