java中连续减少时间,格式为HH:MM:SS
我有一个在项目中实施投标系统的方法,在服务器上的拍卖表中,我有一个用于开始时间和结束时间的字段。
我正在做的是,当用户搜索时,他当然只会看到拍卖仍在进行中的项目。
当用户点击该项目时,他会被购买到可以出价的页面。在那里我得到开始时间和结束时间之间的间隔,然后开始减少时间。
是否有任何现有代码可用于减少
java 中格式为 hh:mm:ss 的
时间?
编辑:问题中有一个错误,结束时间和当前时间之间的时间减少的时间
I have a to implement a bidding system in a project and on the server, in the auction table, i have a field for start time and end time.
What I am doing is that when a user searches, of course he sees only item whose auction is still open
When the user click on the item, he is bought to a page where he can bid. There I get the interval between the start time and the end time and then i start decreasing the time.
is there any existing code that can be used to decrease a time whose format is in
hh:mm:ss in java
??
Edit:there was an error in the questiom, the time to decrease in the time between the end time and the current time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不需要减少时间。您需要显示还剩多少时间。即现在与结束时间之间的间隔。您使用的是 Java 客户端吗?或者您需要使用 Java 脚本编写代码吗?
编辑:假设出价于 12:00:00 结束,当前时间为 11:59:20(还剩 40 秒),您将计算以下结果。
您始终根据参考时间计算时间,因此随着时间的推移 currentTimeMillis() 自然不需要减少任何内容。
You don't need to decrease the time. You need to show how much time is remaining. i.e. the interval between now and an end time. Are you using a Java client? Or do you need the code to be in Java script?
EDIT: Say the bid ends at 12:00:00 and the current time is 11:59:20 (40 second to go) You would calculate the following.
You are always calculating the time against a reference time so there is no need to decrement any thing as time progresses in currentTimeMillis() naturally.
我想我将继续使用以下方式,因为我不想依赖客户时间:
->从服务器获取所需的拍卖
->使用服务器时间,计算剩余时间(即当前服务器时间-拍卖结束时间)
->将剩余时间发送给客户端
->在客户端减少直到 0 秒
I think i will proceed using the following way because i don't want to rely on client time:
-> get the required auction from the server
-> using server time, calculate the remaining time (i.e. Current Server Time- auction end time)
-> Send remaining time to client
-> at client decrease until 0 Second