How to check real time

Discussion in 'Plugin Development' started by MYCRAFTisbest, May 12, 2013.

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

    MYCRAFTisbest

    I forget how to do this, but I think it was fairly simple.
    Could someone remind me how to check the current real (not in-game) time?

    Thanks
     
  2. Offline

    caseif

    System.getCurrentTimeMillis()
     
  3. Offline

    MYCRAFTisbest

    Thanks.
     
  4. Offline

    Scizzr

    Code:
    Calendar cal = Calendar.getInstance();
    int y = cal.get(Calendar.YEAR);
    int m = cal.get(Calendar.MONTH);
    String mm = (new DateFormatSymbols()).getMonths()[m];
    int d = cal.get(Calendar.DAY_OF_MONTH);
    int h = cal.get(Calendar.HOUR_OF_DAY);
    int i = cal.get(Calendar.MINUTE);
    int s = cal.get(Calendar.SECOND);
     
    String date = String.format("Today is %s %d, %d", mm, d, y);
    String time = String.format("The time is currently %d:%d:%d", h, i, s);
    
    Untested, but should work.
     
Thread Status:
Not open for further replies.

Share This Page