Examples of ParsePosition


Examples of java.text.ParsePosition

      final String X = UTF8.String(dcipher.doFinal(A));

      System.out.println("TEST: detecting X-String      : " + X);

      // reconstruct the properties
      final Date   inFileDate     = dateFormatter.parse(X.substring(0, 17), new ParsePosition(0));
      final Date   encryptionDate = dateFormatter.parse(X.substring(17, 34)new ParsePosition(0));
      final long   inFileSize     = Base64Order.standardCoder.decodeLong(X.substring(34, 45));
      final String flag           = X.substring(45, 46);
      final String origFileName   = X.substring(46);

      System.out.println("TEST: detecting inFileDate    : " + inFileDate);
View Full Code Here

Examples of java.text.ParsePosition

  public boolean validate() {
    boolean valid = true;
    valid = valid && !text.isEmpty("guidemo.form.error.notempty");
    valid = valid && date.matches("\\d{2}\\.\\d{2}\\.\\d{4}", "guidemo.form.error.date");
    Date d = new SimpleDateFormat("dd.MM.yyyy").parse(date.getValue(), new ParsePosition(0));
    if (d == null) {
      date.setErrorKey("guidemo.form.error.date");
      return false;
    }
    return valid;
View Full Code Here

Examples of java.text.ParsePosition

      LengthUnit.INCH.getFormat().parseObject("10,2'");
      fail("10,2' not a number"); // Accept fraction part only for inches
    } catch (Exception ex) {
      // Expected a failure
    }
    ParsePosition parsePosition = new ParsePosition(0);
    LengthUnit.INCH.getFormat().parseObject("10'2A", parsePosition);
    assertEquals("Wrong parse position", "10'2A".indexOf('A'), parsePosition.getIndex());
  }
View Full Code Here

Examples of java.text.ParsePosition

        setDisplay(date);
    }


    public boolean setISODate(String isoDate) {
        Date d = new SimpleDateFormat(ISO_PATTERN).parse(isoDate, new ParsePosition(0));
        if (d != null)
            setDate(d);
        return d != null;
    }
View Full Code Here

Examples of java.text.ParsePosition

        result = new EmailMsg( id );

        result.setModified( false );
        result.setInDatabase( true );

        ParsePosition pos = new ParsePosition(0);
        java.util.Date recvDate =
          this.dateFmt.parse( rs.getString( col++ ), pos );
        result.setReceiveDate( recvDate );

        result.setMessageID( rs.getString( col++ ) );
View Full Code Here

Examples of java.text.ParsePosition

        result = new EmailMsg( id );

        result.setModified( false );
        result.setInDatabase( true );

        ParsePosition pos = new ParsePosition(0);
        java.util.Date recvDate =
          this.dateFmt.parse( rs.getString( col++ ), pos );
        result.setReceiveDate( recvDate );

        result.setMessageID( msgId );
View Full Code Here

Examples of java.text.ParsePosition

    for (int i = 0; i < patterns.length; i++) {
      Date date = null;
     
      SimpleDateFormat dateFormat = new SimpleDateFormat(patterns[i]);     
      dateFormat.setLenient(false);     
      ParsePosition pos = new ParsePosition(0);
     
      date = dateFormat.parse(dateTimeString, pos);
     
      if (date != null && (pos.getIndex() == dateTimeString.length()))
        result = new ParsedDate(date, dateFormat);
     
      // introduce the y10k problem && ignore everything B.C
      // needed to escape SimpleDateFormats broken guesswork that can produce corrupt Dates.
      if (result != null) {
View Full Code Here

Examples of java.text.ParsePosition

      if (time==-1) {
        long foundTime = NOTIME;
          // if not DEVELOPMENT version, read time text using format used to set time
            try {
                SimpleDateFormat format = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
                ParsePosition pos = new ParsePosition(0);
                Date date = format.parse(time_text, pos);
                if (date!=null) foundTime = date.getTime();
            } catch (Throwable t) {           
            }
            time = foundTime;
View Full Code Here

Examples of java.text.ParsePosition

    Calendar cal = new GregorianCalendar(1962, 0, 19, 8, 40);
    Date myBirthDay = cal.getTime();
    ISO8601DateTimeFormat formatter = new ISO8601DateTimeFormat();
    String serial = formatter.format(myBirthDay);

    ParsePosition pos = new ParsePosition(0);
    Date parsedDate = formatter.parse(serial, pos);
    assertNotNull(
      "Parsing of " + serial + " failed at position " + pos.getIndex(),
      parsedDate);
    assertEquals(
      "ISO 8601 date parser produces wrong result",
      myBirthDay,
      parsedDate);
View Full Code Here

Examples of java.text.ParsePosition

   */
  public void testParseException() {
    String wrong = "1999-mar-01T00:00:00Z";
    ISO8601DateTimeFormat formatter = new ISO8601DateTimeFormat();

    ParsePosition pos = new ParsePosition(0);
    Date res = formatter.parse(wrong, pos);

    assertNull("A null value should have been returned.", res);

    assertEquals(
      "The wrong parse position is reported in case of error.",
      5,
      pos.getErrorIndex());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.