Solved TimeUnit

Discussion in 'Plugin Development' started by MaTaMoR_, Feb 25, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    Ey how can i fix this ?

    I wanna get the time remaining but this ain't working right.
    2. public String timeRemaining(Long unbandate) {
    3. Long now = System.currentTimeMillis();
    4. Long date = unbandate - now;
    5. String days = String.valueOf(TimeUnit.MILLISECONDS.toDays(date));
    6. String hours = String.valueOf(TimeUnit.MILLISECONDS.toHours(date));
    7. String minutes = String.valueOf(TimeUnit.MILLISECONDS.toMinutes(date));
    9. String fulldate = days+" d "+hours+" h "+minutes+" m";
    10. return fulldate;
    11. }

    Photo //This should display only 2 hours
  2. Offline


    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)
  3. Offline

    1Rogue Retired Staff

  4. 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.
    MaTaMoR_ likes this.
  5. Offline


    That ain't the problem .

    That helped a lot .

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 13, 2016
Thread Status:
Not open for further replies.

Share This Page