Start a minute counter for every newly added item [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am developing a website where the users will add items they want to sell.
I am now trying to figure out a way how to place a munite counter for every newly added item. I need the counter to start from 0 and count every minute the item has been active. I also need the counter to reset at the end of every month and start again from 0 in the beginning of the next month.
Do you have any suggestions where I can start from?
I will appreciate any help here.
Thanks a lot!

If I were you I would store the creation date inside a database and derive the number of minutes it has been available from it. If you're going to store a counter in memory things won't scale, apart from the fact that in case of failure you would lose all information.

Related

How can I know which days are occupied in my hotel management system? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 15 hours ago.
Improve this question
I'm a rookie and I've been tasked with creating a hotel manager for a course I'm doing. Nothing too fancy, just some application which is handled by a receptionist and is never used by the customer. It goes like this. Some customer calls the hotel and asks the receptionist: "Hey, is there any single room available from Friday 12th to Thursday 18th?" And the receptionist checks it and makes the reservations if everything is ok.
This other question (Enter an array of objects into an Arraylist of objects and change attribute) is alike, but I'd wish for that variable "Occupied" or another Boolean variable called "Reserved" to be present every day it's reserved. Thank you in advance.

How can I limit the user to add only one item to a ResycleView per day in kotlin [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
is there a way to make the user add just one item per day, then get an alert saying "only one time a day"
what to use, coroutine, tasktimer, work manger ?
I will try and give a general answer.
Usually when it comes to such requirements it is good to compare the date and time of the last item that was created and the current date and time. That means you would need to store the item in a database.
The reason I'm suggesting such an approach is because a user might close your app, or the OS might put it to sleep / terminate it and all of your tasks and timers might be stopped. By having it persisted in a DB, you can always be sure your requirements are met.
For example if the requirement is 24 hours or perhaps just a calendar day (after midnight), then you would do the comparison and know if they have been met and allow the creation of new items, or not.
Additionally, it's always good to try and experiment at first. See what works and what doesn't before asking your question.
Good luck.

How to expire One-time Password after N number of attempts [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
If someone tries to login for 5 times the otp should expire when the user tries it for the 6th time.
Any suggestions will be appreciated.
Increase the counter for each incorrect code entry and when it reaches 6 show an error
Without any further information what your OTP system is or anything, all we can do are educated guesses.
First, I have to guess what your actual problem is, because the answer is too obvious.
You have a counter (saved whereever the OTP is saved), and for each bad attempt you add 1. When it reaches 6, you delete the OTP from the database/service/whatever, and show the user a warning that you have done so. Then you reset the counter to 0 (for the new password).
Upon successfully entering the password, you also reset the counter.

How to set a restriction for each phone/user on my app? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm starting to build an app where people vote certain stuff just by clicking on happy/sad faces (kind of like grading it). The thing is that I dont want to make a log-in nor registration for my app (the reason is a long story). So is there any way that I can limit people's vote to 2 per day? Every phone/user could only vote twice a day, and that count will reset after 24h from the first vote.
You have tow options:
Limit the number of votes on the device, by saving the number of votes into persistant storage on the device with a timestamp and act accordingly.
Or (more secure, but also more difficult)
Track the installations as described here identifying app installation
And send the id with every request and validate on the server side.

How can i do performance counting in Java SE on Windows and Linux? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
how can i do performance counting in Java SE on Windows and Linux?
How are people do this? I want to monitor messages/events per second etc
Thanks
Performance counters are no different to other counters. You increment a number and every so often, you divide this number by the time elapsed.
basically (this is made simple and just for one thread in mind):
1.)start timer
have a private counter
2.)increment every time something happens
3.)after one second passed display the number in the counter
4.)reset the counter
5.)Go to step 1.)

Categories