hi everyone. I am doing a project in jsp where i need to check the duration of logins of a particular client. If the client doesnot login for 6 months(say) his account should expire. For this purpose i am taking system date and storing it in sql database. I have problems in converting a java.util.date to java.sql.date. I need to update the system date(from jsp code) everytime the user logs in, to sql database. For this purpose i am using simple Update statement.
Data type in sql is Date. and datatype in jsp is SimpleDateFormat(yyyy-MM-dd).(i need only yyyy-MM-dd format)
SimpleDateFormat abc = new SimpleDateFormat( "yyyy.MM.dd" );
Date now= new Date();
dbst.executeUpdate("update dates set date2 = '"+(dont know what to give)+"' where username ='xyz'");
I am using 2 date columns one for getting latest date and the other for old date. then i can find out the date difference. I must also compare the dates before updating them to database. For this purpose i must compare the already existing dates with current user(from jsp) date.
Friends please help me in converting the dates. Thanx in advance.