commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lance Semmens <lance.semm...@essential.com.au>
Subject RE: TimeStamp validator
Date Wed, 27 Apr 2005 23:38:05 GMT
Your date pattern is "dd/MM/yyyy hh:mm:ss"
If you are expecting 24 hour time, you should use HH instead of hh.

-----Original Message-----
From: Rodolfo García Esteban/CYII [mailto:rgarciaesteban@cyii.es]
Sent: Wednesday, 27 April 2005 6:19 PM
To: Jakarta Commons Users List
Subject: Re: TimeStamp validator
Importance: Low


Hola Jose Antonio.

This is the code.

                if (entradaString != null && !entradaString.equals("")) {
                        bEntradaEnter = true;
                        log.trace("La fecha es ||" + entradaString + 
"||");
                        if (GenericValidator.isDate(entradaString, 
"dd/MM/yyyy hh:mm:ss", false)) {
                                try {
                                        entrada = 
sdf.parse(entradaString);
                                }
                                catch (ParseException pe) {
                                        errors.add("entradaString", new 
ActionMessage("errors.formato.fecha", "Entrada"));
                                        log.error("Error al convertir 
fecha Entrada " + entradaString);
                                }
                        }
                        else {
                                errors.add("entradaString", new 
ActionMessage("errors.formato.fecha", "Entrada")); 
                                log.trace("Entrada no es una fecha 
correcta. dd/MM/yyyy " + entradaString);
                        }
                }

I have rewrite the pattern and works well. Thank you,

Gracias saludos

________________________
Rodolfo 
_______________________




José Antonio Pérez Testa <japtesta@indra.es>
27/04/2005 10:16
Por favor, responda a "Jakarta Commons Users List"

 
        Para:   Jakarta Commons Users List <commons-user@jakarta.apache.org>
        cc:     (cco: Rodolfo García Esteban/CYII)
        Asunto: Re: TimeStamp validator


Hola Rodolfo,
The javadoc for isDate states that the pattern is used with 
SimpleDateFormat.
Maybe your pattern is not correct for the validation your need.
Can you give us the pattern and the String to validate.



public static boolean *isDate*(java.lang.String value,
                             java.lang.String datePattern,
                             boolean strict)

Checks if the field is a valid date. The pattern is used with 
|java.text.SimpleDateFormat.


|Rodolfo García Esteban/CYII wrote:

>Hi,
>
>I use GenericValidator.isDate(), when I try to 
>validate with the pattern "dd/MM/yyyy" works well, but when I use the 
>pattern "dd/MM/yyyy hh:mm:ss", doesn't work well, it returns false when 
>checks a valid string. How  I can validate this pattern date?. Is there 
>any timeStampValidator or something like that?
>
>Thanks in advance,
>
>________________________
>Rodolfo 
>
> 
>

-- 

José Antonio Pérez Testa
Ingeniería de Servicios e Innovación técnologica.

Telémaco 3
28027 - Madrid (ESPAÑA)
Tel: +34-91-480.81.12
 
japtesta@indra.es
www.indra.es


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message