The Artima Developer Community
Sponsored Link

Java Answers Forum
NOW

2 replies on 1 page. Most recent reply: Jul 12, 2004 12:47 AM by Nick

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Nick

Posts: 9
Nickname: nicolashad
Registered: Jul, 2004

NOW Posted: Jul 2, 2004 9:11 AM
Reply to this message Reply
Advertisement
Hi!
I'll do write down a code's line that take the "now" from the system and put it in a object "Date today" where "today = new date()"..Soeone know if exist a fuction able to do it?
Thanks


Jeroen Wenting

Posts: 88
Nickname: jwenting
Registered: Mar, 2004

Re: NOW Posted: Jul 10, 2004 10:37 AM
Reply to this message Reply
have you tried?
Because if you had you'd have known that the code example you give is almost exactly what you need, just make sure you get the classname for Date correct...

Nick

Posts: 9
Nickname: nicolashad
Registered: Jul, 2004

Re: NOW Posted: Jul 12, 2004 12:47 AM
Reply to this message Reply
Hi,I've wrote this:

% java.sql.Connection conn = java.sql.DriverManager.getConnection((String)
request.getAttribute("DBConnectio n"), "", "");
sql.PreparedStatement ps = conn.prepareStatement("select * from percorsi);
java.sql.ResultSet rs = ps.executeQuery();
while (rs.next()) {
String id = (String) rs.getString(1);
String e = (String) rs.getString(5);
Date E = Date.valueOf(e);
String t = (String) rs.getString(9);/*take the date of system know as "now"..*/
Date T = Date.valueOf(t);
if (E.before(T) =true) {

java.sql.PreparedStatement ps2 = conn.prepareStatement("update percorsi set stato = ? where id_percorso = ?");
ps2.setString(1, "N");
ps2.setString(2, id);
int result2 = ps2.executeUpdate();

rs2.close();
ps2.close();
}
rs.close();
ps.close();

Flat View: This topic has 2 replies on 1 page
Topic: silent install (need help) Previous Topic   Next Topic Topic: do while help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use