Best way to store times

Discussion in 'Plugin Development' started by dlange, Jun 15, 2015.

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

    dlange

    What is the best way to store times?
    I am doing a punishments plugin. I am storing it in an SQL database. And i need it to store how long they will be banned and unban them when the timer is up. The way to unban then will vary on how i do the time but i don't know what the best way to get and store the times is.
    Thanks for any help :)
     
  2. Offline

    caderape

    @dlange system.currentmillis is the best way to do it. Divide it by 1000 and it return the time since minecraft is created in second. Player with it for punishment time.
     
  3. Offline

    RainoBoy97

    DATETIME
    java.sql.Date
    java.util.Date
     
  4. Since minecraft was created, really?

    As for OP @dlange
    get the millis and then use TimeUnit :)
     
  5. Offline

    Tecno_Wizard

    That is horrifically wrong. It is the number of milliseconds since Jan 1, 1970 for Java and has NOTHING to do with Minecraft.

    @dlange
    Your best bet is to store the time to unban them and every once in a while (I'd do every few min) loop through the bans and see if any of then have expired (async!) Use the millisecond representation.
     
  6. Offline

    dlange

    Ok thanks everyone! I will try this and get back to you when i'm done :)
     
Thread Status:
Not open for further replies.

Share This Page