Hi everyone and thanks for your attention.

First of all, I notice I'm using JRE 1.3.1_11.

I have a method that returns a string representation of the actual date in the format "yyyy-MM-dd HH:mm:ss", which I use to insert into a database.

It works properly almost always but sometimes(once every 500 more or less) it produces an odd output.

For example it created the following output:
2005-0012-20 00:45:49

when the input date was 2006-01-20 and the time was about 07:45.

This is the code I'm using:

String stFechaActual=objDBAccess.getDateTimestamp();
FormatDate formatoFecha = new FormatDate(stFechaActual);
String fechaFormateada = formatoFecha.toStringForUpdate();


The methods and class variables used in my FormatDate class are:

static final SimpleDateFormat ISO1 =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
static final SimpleDateFormat DATEARQ = ISO1;

public FormatDate(String cadena) {
try {
calendario = Calendar.getInstance();
if (cadena.startsWith("'")) cadena = cadena.substring(1);
if (cadena.endsWith("'")) cadena = cadena.substring(0, cadena.length()-1);
//calendario.setTime(ISO2.parse(cadena));
calendario.setTime(DATEARQ.parse(cadena));
} catch (ParseException e) {
//objTraza.error("Fecha de entrada con formato distinto al de BBDD");
}

}

public String toStringForUpdate ()
{
return "to_date('"+this.toString()+"','YYYY-MM-DD hh24:mi:ss')";
}

public String toString() {
return DATEARQ.format(calendario.getTime());
}

The problen occurs in the method toStringForUpdate, in the this.toString() call

Thanks in advance