You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Frédérick, Fabian" <fa...@prov-liege.be> on 2005/08/11 09:21:50 UTC
[OT] Date conversion problem
Hi :)
I'm trying to convert inpuDate passed in String to my bean with the
following (in order to extract year ... for database).
(ddepart is inputdate string).
Date dimport = new Date();
DateFormat df = new SimpleDateFormat ("EEE MMM d hh:mm:ss z yyyy");
try{
dimport = (Date)df.parse(ddepart);
}catch (Exception e){
System.out.println("!!!"+e) ;
}
It doesn't seem to work....Is there an error in simpledateformat ?
Best regards,
Fabian
Re: [OT] Date conversion problem
Posted by Matt Blum <mb...@gmail.com>.
Without knowing what the input was, it's a little difficult to know why it
failed. SimpleDateFormat's parse method has no bugs I'm aware of, so my
suspicion is that the String you're sending to the method isn't in precisely
the format you specified. The time zone looks like it's in a strange place
to me (shouldn't it be after the year?) but I could be wrong about that.
-Matt
On 8/11/05, "Frédérick, Fabian" <fa...@prov-liege.be> wrote:
>
> Hi :)
>
> I'm trying to convert inpuDate passed in String to my bean with the
> following (in order to extract year ... for database).
>
> (ddepart is inputdate string).
>
> Date dimport = new Date();
> DateFormat df = new SimpleDateFormat ("EEE MMM d hh:mm:ss z yyyy");
> try{
> dimport = (Date)df.parse(ddepart);
> }catch (Exception e){
> System.out.println("!!!"+e) ;
> }
>
> It doesn't seem to work....Is there an error in simpledateformat ?
>
>
> Best regards,
> Fabian
>
>
>