H
HS1
Hello
I want to compare two dates.
One date is from a database in the form of yyyy-mm-dd (such as 2004-11-29).
I know this because I print the date using the function:
System.out.println(databaseDate.toString());
Now I want to use the funtion "before" for comparing myDate and
databaseDate. So I create a new Date
Date myDate = new Date(2004, 11, 23);
And then I use the function myDate.before(databaseDate) to compare them.
if (myDate.before(databaseDate))
...... do something.....
However, this fuction did not work.
I check myDate using myDate.toString(), got:
Fri Dec 23 00:00:00
It can be seen that myDate and databaseDate are in different format.
Could you please help how to compare them
One more thing. If I want to allow users to enter in a JTextField (instead
of a fixed date (2004, 11, 23)) to compare with a databaseDate, what is
simple way to do that???
Thank you
I want to compare two dates.
One date is from a database in the form of yyyy-mm-dd (such as 2004-11-29).
I know this because I print the date using the function:
System.out.println(databaseDate.toString());
Now I want to use the funtion "before" for comparing myDate and
databaseDate. So I create a new Date
Date myDate = new Date(2004, 11, 23);
And then I use the function myDate.before(databaseDate) to compare them.
if (myDate.before(databaseDate))
...... do something.....
However, this fuction did not work.
I check myDate using myDate.toString(), got:
Fri Dec 23 00:00:00
It can be seen that myDate and databaseDate are in different format.
Could you please help how to compare them
One more thing. If I want to allow users to enter in a JTextField (instead
of a fixed date (2004, 11, 23)) to compare with a databaseDate, what is
simple way to do that???
Thank you