Date and format.

Discussion in 'Plugin Development' started by Deleted user, Jun 20, 2014.

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

    Deleted user

    Okay so basically I'm trying to do something within my plugin ever 24 hours..
    So I've added the date to the config:
    2. Date date = new Date();
    3. SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
    4. format.format(date);
    5. config.set("DATE", date);

    And that comes out like so..
    DATE: 2014-06-20T18:47:12.710Z
    Okay so first of all two problems with that..
    It's displaying time which is unnecessary, and it's coming out as

    And while I'm here I might as well as this considering this is the first time I've ever messed with dates and time.

    Does this seem like it would work..
    2. String currentDate = config.getString("DATE");
    3. String lastRefresh = config.getString("LAST_REFRESH");
    5. if (lastRefresh == null || lastRefresh != currentDate) {
    6. Date date = new Date();
    7. SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
    8. format.format(date);
    9. config.set("LAST_REFRESH", date);
  2. Offline


    Try putting the format.format(date) on the config.set instead of date
  3. Offline

    Deleted user

    Will try that, does my method for checking if 24 hours has passed look logical?
  4. Offline


    Eballer48 Well you are checking if it isn't equal when you should be checking if its 24 hours later
  5. Offline

    Deleted user

    Right I just did that because technically if it was 24 hours later it wouldn't be equal. But how would I check if it's 24 hours later? Would I need to split the String?
  6. Offline


    Eballer48 You can do date.getDays and date.getMonths there is probably a better way but check if the month is 1 more then run the stuff if it is but if it isn't then check if the day is 1 more then run it if it is Oh yeah and also put a little time check in if it is exactly 1 more day then if it is make sure the time is after what it was on the original

    Sorry if I didn't explain that well
Thread Status:
Not open for further replies.

Share This Page