Ey how can i fix this ? I wanna get the time remaining but this ain't working right. Code:java public String timeRemaining(Long unbandate) { Long now = System.currentTimeMillis(); Long date = unbandate - now; String days = String.valueOf(TimeUnit.MILLISECONDS.toDays(date)); String hours = String.valueOf(TimeUnit.MILLISECONDS.toHours(date)); String minutes = String.valueOf(TimeUnit.MILLISECONDS.toMinutes(date)); String fulldate = days+" d "+hours+" h "+minutes+" m"; return fulldate;} Photo //This should display only 2 hours
the days don't work because the time is less than a day, hours work and minutes won't work because u turn the time turned to hours previously, to minutes. So after turning it to hours, in minutes thingy get: 60*hours%minutes. (Not sure tho, haven't tested)
TimeUnit is really. really bad for this: https://github.com/CodeLanx/Codelan...anx/codelanxlib/util/time/TimePoint.java#L275 You need to take your newly converted value, convert it back, and subtract it from the previous amount (when using TimeUnit).
It would be better you get the difference between the two times. For doing a temp ban plugin, I used this to help me with the timed unbans and unmutes.
That ain't the problem . That helped a lot . EDIT by Moderator: merged posts, please use the edit button instead of double posting.