aspose file tools*
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
Author

Cookbook Question: comparing sql.Date/Time

Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5018
    
    8

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

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

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

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

Joined: Feb 26, 2001
Posts: 5018
    
    8

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: http://aspose.com/file-tools
 
subject: Cookbook Question: comparing sql.Date/Time