package commands; import java.io.*; import java.util.Date; import kernel.*; /** * Prints the current date. * * @author Tomáš Podskalský */ public class date extends AbstractProcess { public void realization() throws AppException { PipedOutputStream output = (this.getOut() != null) ? (PipedOutputStream) this .getOut() : null; try { String s = new String((new Date()).toString() + "\n"); output.write(s.getBytes()); output.flush(); } catch (IOException ioe) { ioe.printStackTrace(); throw new AppException("Chyba I/O\n" + ioe.getMessage(), ioe); } catch (NullPointerException npe) { npe.printStackTrace(); throw new AppException("Output není definován\n" + npe.getMessage(), npe); } catch (Exception e) { e.printStackTrace(); throw new AppException("Neznámá Chyba.\n" + e.getMessage(), e); } } /** * Provides help for users. * */ public String getHelp() { return "\n\nDescription:\nPrints the current date.\n\n"; } }