Erro com dia 29/02 no Apache Commons Net

0 respostas
G

Boa tarde,

Estou com problema na biblioteca commons net quando vou baixar um arquivo que a data é o dia 29/02.

O erro acontece no método parseTimestamp da classe FTPTimestampParserImpl.

Abaixo segue o código:

public Calendar parseTimestamp(String timestampStr) throws ParseException {
		Calendar now = Calendar.getInstance();
		now.setTimeZone(this.getServerTimeZone());
		
		Calendar working = Calendar.getInstance();
		working.setTimeZone(this.getServerTimeZone());
		ParsePosition pp = new ParsePosition(0);

		Date parsed = null;
		if (this.recentDateFormat != null) {
			parsed = recentDateFormat.parse(timestampStr, pp);
		}
		if (parsed != null && pp.getIndex() == timestampStr.length()) 
		{
			working.setTime(parsed);
			working.set(Calendar.YEAR, now.get(Calendar.YEAR));
			if (working.after(now)) {
				working.add(Calendar.YEAR, -1);
			}
		} else {
			pp = new ParsePosition(0);
			parsed = defaultDateFormat.parse(timestampStr, pp);
			// note, length checks are mandatory for us since
			// SimpleDateFormat methods will succeed if less than
			// full string is matched.  They will also accept, 
			// despite "leniency" setting, a two-digit number as
			// a valid year (e.g. 22:04 will parse as 22 A.D.) 
			// so could mistakenly confuse an hour with a year, 
			// if we don't insist on full length parsing.
			if (parsed != null && pp.getIndex() == timestampStr.length()) {
				working.setTime(parsed);
			} else {
				throw new ParseException(
					"Timestamp could not be parsed with older or recent DateFormat", 
					pp.getIndex());
			}
		}
		return working;
	}

O parâmetro timestampStr está com o valor: Feb 29 15:47 e a mensagem da exceção lançada é: Timestamp could not be parsed with older or recent DateFormat.

O erro está comigo ou é da biblioteca?

Como posso corrigir ou contarnar esse problema?

Agradeço pela atenção.

Sem mais,
Gustavo Martim.

Criado 11 de julho de 2008
Respostas 0
Participantes 1