Solved Date does not change!

Discussion in 'Plugin Development' started by zDubsCrazy, Feb 4, 2015.

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

    zDubsCrazy

    I am using the following code to get the date and time currently:

    .
    Code:
    Date now = new Date();
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    String hour = format.format(now);
    Whenever I use the String 'hour', she always returns the same value.

    Thanks in advance.
     
  2. Offline

    RainoBoy97

    That's because you are using the same variable over and over, if you want it to update you need to create a new Date object each time (no need to create a new SimpleDateFormat) :p
     
    zDubsCrazy likes this.
  3. Offline

    zDubsCrazy

  4. Offline

    Burnett

    Never knew there are genders for code. :p
     
    Last edited: Feb 4, 2015
  5. Offline

    zDubsCrazy

    @Burnett
    Complain to the Google translator, he made that mistake.
     
    leon3001 likes this.
Thread Status:
Not open for further replies.

Share This Page