Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: how to convert a string to date?


Message #1 by "Roy Ngan" <bean_00@h...> on Tue, 6 Feb 2001 02:11:53 -0000
Hi
You can always store what you get from a previous page in  a session and
retrieve it in the next page. In our example, you could say
session.putValue("date", NwsDate);
In your next page just retrieve the value from the session:
String sessionDate = session.getValue("date");
And then using the date constructor which takes string as a parameter you
can convert string to date.
Date newDate = new Date(sessionDate);
This is of course deprecated api  but should work.

Hope this is what you are looking for.

Yamini

----- Original Message -----
From: "Roy Ngan" <bean_00@h...>
To: "Pro_JavaServer_Pages" <pro_jsp@p...>
Sent: Tuesday, February 06, 2001 7:41 AM
Subject: [pro_jsp] how to convert a string to date?


>
>
> Dear all,
>
>     Does anyone know how to convert a String to date? or retrieve a Date
> from previous page?
>
> I'm getting a date from a previous jsp page by using the statement:
>
> String NwsDate = request.getParameter("NwsDate");
>
> after that I need to add the value using a PreparedStatement
>
> String sqlNws = "Update News set NwsDate=? where NwsId=?";
> PreparedStatement stt = dbCon.prepareStatement(sqlNws);
> stt.setDate(1, NwsDate);
> stt.setString(2, NwsId);
> stt.executeUpdate();
>
> Anyone know how to perform this or is there any alternative solution to
> retreive a date from previous page and store it into database using
> prepared statement?


  Return to Index