Package java.text

Examples of java.text.ParsePosition


        lastReply = control.sendCommand("MDTM " + remoteFile);
        lastValidReply = control.validateReply(lastReply, "213");

        // parse the reply string ...
        Date ts = tsFormat.parse(lastValidReply.getReplyText(),
                                 new ParsePosition(0));
        return ts;
    }
View Full Code Here


            // Format the current time.
            SimpleDateFormat formatter = new SimpleDateFormat(timePattern);

            Date d = null;
            try {
                d = formatter.parse(dateStr, new ParsePosition(0));
            } catch (Exception e) {
              if(this.traceEnabled)
                traceLog.warn(
                    String.format("Failed to parse date string \"%s\" using pattern \"%s\". Cause: %s",dateStr,timePattern,e.getMessage()));
            }
View Full Code Here

    String sHour = _hourField.getText()+dateSeparators[HOUR_POS];
    String sMinute = _minuteField.getText()+dateSeparators[MINUTE_POS];
    String sSecond = _secondField.getText()+dateSeparators[SECOND_POS];
    String sMillisecond = _millisecondField.getText();
    String sTime = sHour+sMinute+sSecond+sMillisecond;
    ParsePosition pos = new ParsePosition(0);
    dateTmp = fmt.parse(sDate+sTime, pos);
    if( pos.getIndex() == 0 )
      throw new NumberFormatException("Invalid date.");

    return dateTmp;
  }
View Full Code Here

            pattern = dateFormats[2];                       // ddMMMyyyy
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        //sdf.setLenient(true);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        ParsePosition p = new ParsePosition(0);
        Date          d = sdf.parse(tstart, p);
        if (d == null) {
            System.out.println("couldn't parse at " + p.getErrorIndex());
            d = new Date(0);
        }
        //System.out.println("start = " + d);
        // set the unit
        sdf.applyPattern("yyyy-MM-dd HH:mm:ss Z");
View Full Code Here

    public List<Date> getDates() {
        if ((dates == null || dates.isEmpty()) && !dateList.isEmpty()) {
            dates = new ArrayList<Date>(dateList.size());
            dateFmt.setTimeZone(TimeZone.getTimeZone("GMT"));
            for (String dateString : dateList) {
                Date d = dateFmt.parse(dateString, new ParsePosition(0));
                //DateFromString.getDateUsingSimpleDateFormat(dateString,
                //    DATE_FORMAT);
                dates.add(d);
            }
        }
View Full Code Here

        String reply = control.sendCommand("MDTM " + remoteFile);
        lastValidReply = control.validateReply(reply, "213");

        // parse the reply string ...
        Date ts = tsFormat.parse(lastValidReply.getReplyText(),
                                 new ParsePosition(0));
        return ts;
    }
View Full Code Here

    }
    return type;
  }

  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 (value == null || value.length() == 0)
      return parsedNullOrEmpty;
    else if (value.equals(formattedNull))
      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

    public Date getDate()
    {
        SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmssz");

        return dateF.parse(this.getTime(), new ParsePosition(0));
    }
View Full Code Here

      final String inFileSize       = Base64Order.standardCoder.encodeLongSB(inFile.length(), 11).toString(); // 64 / 6 = 11; 11 byte
      final String flag             = "1"; // 1 byte
      //int    inFileNameLength = inFileName.length(); // 256
      final String X                = inFileDate + encryptionDate + inFileSize + flag + inFileName;

      System.out.println("TEST: preserving inFileDate    : " + dateFormatter.parse(inFileDate, new ParsePosition(0)));
      System.out.println("TEST: preserving encryptionDate: " + dateFormatter.parse(encryptionDate, new ParsePosition(0)));
      System.out.println("TEST: preserving inFileLength  : " + inFile.length());
      System.out.println("TEST: preserving flag          : " + flag);
      System.out.println("TEST: preserving inFileName    : " + inFileName);
      System.out.println("TEST: preserving X-String      : " + X);
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.