date comparison

Reply

Join Date: May 2007
Posts: 30
Reputation: akash_msrit is an unknown quantity at this point 
Solved Threads: 0
akash_msrit akash_msrit is offline Offline
Light Poster

date comparison

 
0
  #1
Jul 24th, 2007
Hi,

I have a html table , in table i am displaying dates in column called date, now i want to compare dates in the date column with current system date.
if any one have existing code(in jsp ,javascript) for this please forward me or any advise and suggestions are appriciated.

query 2:

i have two date columns (called startdate, enddate)in my database ,in that i am displaying one column (enddate)in front end in table format .
now the problem is i have to compare these two fields i.e startdate which is in backend and enddate in which i display in fornt end. and perform some calculation. please tell how to compare these two.

using jsp or javscrip t or any other suggestions are appreciated

Regards
Akash
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,620
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: date comparison

 
0
  #2
Jul 24th, 2007
> i want to compare dates in the date column with current system date.
Check the 'before()', 'after()' and 'equals()' methods of the Date or the Calendar class.

> now the problem is i have to compare these two fields
Without knowing the scenario, it would be difficult to suggest anything. Since one of the values is in the database, do the comparison in the servlet itself.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 30
Reputation: akash_msrit is an unknown quantity at this point 
Solved Threads: 0
akash_msrit akash_msrit is offline Offline
Light Poster

Re: date comparison

 
0
  #3
Jul 25th, 2007
hi

thanks for the reply, i am not able to understand what u have quoted for first query. please give me an example code to compare date column with system date.

Regards
Manjunath
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,620
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: date comparison

 
0
  #4
Jul 25th, 2007
There are a lot many ways of comparing dates depending on the source of dates and which class you are using to represent them (Date, java.sql.Date, Calendar), which would accordingly require some conversion.

Here is a simple example of comparing two java.util.Date objects.
  1. public static void main(String[] args) throws ParseException
  2. {
  3. Date today = new Date();
  4. Date before = new SimpleDateFormat("dd/MM/yyyy").parse("26/07/2007");
  5. if(today.after(before))
  6. {
  7. System.out.println("[" + today + "] lies after [" + before + "]");
  8. }
  9. else
  10. {
  11. System.out.println("[" + today + "] lies before or is the same as [" + before + "]");
  12. }
  13. }
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: date comparison

 
0
  #5
Jul 26th, 2007
but of course you shouldn't do any of that in a JSP as it's not what they're meant for.
In JSTL you could just use < and > to compare context fields containing Dates of course.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC