File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Cookbook Question: comparing sql.Date/Time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Cookbook Question: comparing sql.Date/Time" Watch "Cookbook Question: comparing sql.Date/Time" New topic

Cookbook Question: comparing sql.Date/Time

Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

All right, so this may not be a question directly related to the book but maybe someone knows a good OO recipe for the following problem:
My object persists it's data in several db tables. Each of these tables has change user, change date, and change time information kept in separate fields. The problem is, when I retrieve the data for display, I have to display only one set of the change information fields, i.e. the most recent one made.
Since the number of tables that the data is being stored may change over time, I would like to make the test for which change is the most recent.
What is the best way to do this with java.sql.Date and java.sql.Time?
Thanks in advance,

Junilu - [How to Ask Questions] [How to Answer Questions]
Peter Tran

Joined: Jan 02, 2001
Posts: 783
You can create a class instance variable to hold the most recent date.

NOTE: This is totally a hacked up example. In no way does this example compile, but I hope you get the idea.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

I knew there was a simpler solution than what I had started to formulate yesterday. Just one of those days, I guess. Thanks a bunch!
I agree. Here's the link:
subject: Cookbook Question: comparing sql.Date/Time
jQuery in Action, 3rd edition