java - Remaining time from current time to 18:30 -



java - Remaining time from current time to 18:30 -

i want larn remaining time current time 18.30

my code not working:

long currenttime = system.currenttimemillis(); long endtime = 18:30; long remaining = endtime - currenttime; long hours = remaining / 3600000; long mins = remaining / 60000 % 60; long seconds = remaining / 1000 % 60; string remainingtext = string.format("%02d:%02d:%02d", hours,mins,seconds);

long endbidtime = ();

as know, causes compiler error. comments, seem want set 18:30 on current day. 1 solution utilize date object. first need create date object , set time 18:30. see the javadocs date class details how this. need utilize date.currenttimemillis() right value endbidtime.

you have problem in code:

string remainingtext = "%02d:%02d:%02d".format(hours,mins,seconds);

this wrong , gives other compiler errors. note format() method static. though java allows phone call static method instance variable, discouraged. instead, should utilize class name. also, format string first parameter format() expects. means should following:

string remainingtext = string.format("%02d:%02d:%02d", hours,mins,seconds);

java android eclipse time

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -