In my simple application, I am storing the timestamp into the database table programmatically by using new Timestamp(System.currentTimeMillis()).
Now, I have one condition, where I have to store the onClick count for a particular day, and all onClick counts into two different columns.
So for that, I need to find out onClicks for today. So how can I find out if the time onclicks occur are today? I mean for say 1st August, I want all the onclick counts in one column and all previous onClick counts into another column.
*In simple words – storing clicks for today in one column and storing clicks till now in another column, so if today expires, I want to add clicks for today with total clicks and then make the today_clicks column count to 0 and then when there is new click on next day, store it in the today_clicks column by starting it with count 1*
How can I decide that? Which Java class should I use for that?
If I understand correctly, you are looking for a way to best store your data in your database. You have decided to maintain a clicks-for-today column and a clicks-until-now column. (I may be off base on this, but it wasnt completely clear from the question)
I would suggest that you dont try to manipulate the data from column to column as you have described, but instead do so by maintaining click counts per day:
(where date is a in the db timestamp/date datatype)
How would this work?
At startup, you could then bring into memory all rows, and sum their counts to get a clicks-until-now value, if needed.
You then have special handling for today’s row, where you update the appropriate context with the clicks-for-today value.
To determine whether you’ve passed a day threshold, you could simply:
todayCal)clickCal)todayCalandclickCal