java - How to subtract System.currentTimeMillis() from Hours+Minutes taken from timepicker? -
i want subtract system.currenttimemillis()
hours + minutes taken timepicker. however, system.currenttimemillis()
larger compared hours + minutes converted milliseconds
.
this code:
// setting time in milliseconds. hour1 , minute1 taken timepicker. app.settimemillisdosagetime(timeunit.hours.tomillis(hour1) + timeunit.minutes.tomillis(minute1));
i have timertask
subtracting system.currenttimemillis
.
timertask task = new timertask() { timeinmillis = app.gettimemillisdosagetime(); timertask task = new timertask() { @override public void run() { long ellapsedmillis = timeinmillis - system.currenttimemillis(); } timer = new timer(false); timer.schedule(task,0,1000); } }
but elapsedmillis
negative. solution?
timeunit.hours.tomillis // given number converted milliseconds. if give 1 input 60*60*1000 output. timeunit.hours.tomillis(1) = 60* 60 * 1000 timeunit.minutes.tomillis(1) = 60 * 1000 system.currenttimemillis() //milli seconds elapsed january 1, 1970 utc(coordinated universal time)
but require these hour , minutes set current date, counting how many seconds elapsed 1970.
calendar chosentime = calendar.getinstance(); chosentime.set(calendar.hour_of_day, selectedhour); chosentime.set(calendar.minute, selectedminute); chosentime.gettime().get(time) // gives exact seconds can substracted system.currenttimemillis.
Comments
Post a Comment