• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cookbook Question: comparing sql.Date/Time

 
Junilu Lacar
Bartender
Pie
Posts: 7797
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 7797
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic