使用格式HH:MM:SS连续缩短java时间 [英] Continous decreasing a time in java in format 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
hh:mm:ss in java
??
编辑:在任务中有一个错误,在结束时间和当前时间之间的时间减少
there was an error in the questiom, the time to decrease in the time between the end time and the current time
推荐答案
你不需要减少时间。您需要显示剩余时间。即现在和结束时间之间的间隔。您是否使用Java客户端?或者您需要使用Java脚本中的代码?
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?
编辑:说出价在12:00:00结束,当前时间为11:59:20 40秒钟后)您将计算以下内容。
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.
long endBidTime = .... // today at 12:00:00
long currentTime = System.currentTimeMillis();
long remaining = currentTime - endBidTime;
long hours = remaining / 3600000;
long mins = remaining / 60000 % 60;
long seconds = remaining / 1000 % 60;
String remainingText = "%02d:%02d:%02d".format(hours,mins,seconds);
您总是在参考时间内计算时间,因此无需将任何事物减少为时间在currentTimeMillis()中自然进行。
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.
这篇关于使用格式HH:MM:SS连续缩短java时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!