package net.hyperic.sigar.cmd;

import java.util.Date;

import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException;

public class Who extends SigarCommandBase {

    public Who(Shell shell) {
        super(shell);
    }

    public Who() {
        super();
    }

    public String getUsageShort() {
        return "Show who is logged on";
    }

    public void output(String[] args) throws SigarException {
        net.hyperic.sigar.Who[] who = this.sigar.getWhoList();
        for (int i=0; i<who.length; i++) {
            println(who[i].getUser() + "\t" +
                    who[i].getDevice() + "\t" +
                    new Date(who[i].getTime() * 1000) + "\t" +
                    who[i].getHost());
        }
    }

    public static void main(String[] args) throws Exception {
        new Who().processCommand(args);
    }
}

@@ -47,16 +47,51 @@
 il.Date;
+%0Aimport java.text.SimpleDateFormat;
 %0A%0Aimport
@@ -380,32 +380,181 @@
 ged on%22;%0A    %7D%0A%0A
+    private String getTime(long time) %7B%0A        String fmt = %22MMM dd HH:mm%22;%0A        return new SimpleDateFormat(fmt).format(new Date(time));%0A    %7D%0A%0A
     public void 
@@ -819,23 +819,22 @@
         
-new Dat
+getTim
 e(who%5Bi%5D

format time like the real who command