Getting Real World Time?

Discussion in 'Plugin Development' started by chernobyl360, May 20, 2011.

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

    chernobyl360

    Ok im trying to Create a way to Log Players Joining My Server. In This Log I want it to Show the Date and Time. How Would i do that?

    Would this find The Real World Time? Or Get Server Time " World.getTime() "

    The Logging Code:

    Code:
        try
        {
          BufferedWriter out = new BufferedWriter(new FileWriter("plugins/SmilieJoin/Player.logs", true));
          out.write  + player.getName() + " Logged In At " + World.getTime() " On This Date" ("[" + this.formattedDate + "]
          out.newLine();
          out.close();
        }
        catch (IOException localIOException)
        {
        }
      }
    }
     
  2. I think world.getTime gets the time of the world in minecraft. To find out the current time you'd have to use a different method. There's a built in function to Java to get the date/time etc and i used it in one of my plugins but I've forgotten and am not at my main PC right now.

    If you google java calendar or java date I'm sure you'll turn up something ;)
     
  3. Offline

    chernobyl360

    ok thanks :D
     
  4. Offline

    DreadKyller

    import:
    PHP:
    import java.util.Calendar;
    import java.text.SimpleDateFormat;
    then make a void:

    PHP:
    public String getTime(){
        
    Calendar cal Calendar.getInstance();
        
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return 
    sdf.format(cal.getTime());
    }
     
  5. That's it, @chernobyl360 sorry I couldn't remember :p
     
  6. Offline

    DreadKyller

    actually @Adamki11s : I took your advice, and to figure it out I googled it, lol.
     
  7. I did that first time aswell :p
     
  8. Offline

    DreadKyller

    @Adamki11s : only I googles "java data and time" not "java calender". Also, random sort of, on your HUGE TUTORIAL, your method of saving and loading isn't doing anything at all for me
     
  9. Are you sure you did everything right, It works for a lot of others. If you still can't get it working send me a PM
     
  10. Offline

    DreadKyller

    @Adamki11s : I don't need it anymore anyways, I'm using alta189's SQLLiteLib, which I got working the first try, so I'm sticking with that.
     
  11. That's what I use now as well ;)
     
  12. Offline

    DreadKyller

  13. I know! Trust me once you've learnt SQL quieries it's so nice to use, if you have any problems with SQL quieries let me know and I'll try to help ;)
     
Thread Status:
Not open for further replies.

Share This Page