Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ Views all details of the 1st person in the results of the `find` command.
Clears all entries from the address book. +
Format: `clear`

== Prints out current date and time : `clock`
Format: `clock`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the description for your feature? It is missing.


Example:

* Date & Time now: `DAY`, `DD-MM-YYYY` at `HH:MM:SS` `AM/PM` `SGT`

== Exiting the program : `exit`

Exits the program. +
Expand Down
23 changes: 23 additions & 0 deletions src/seedu/addressbook/commands/ClockCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package seedu.addressbook.commands;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
* Prints date and time at exact moment when user enters "clock" command.
*/
public class ClockCommand extends Command {
public static final String COMMAND_WORD = "clock";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Prints date and time in format: day, date-month-year at hr:min:sec AM/PM timezone.\n"
+ "Example: " + COMMAND_WORD;

@Override

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing header comment. All non-trivial methods should have java doc format header comments.

public CommandResult execute() {
Date now = new Date();
SimpleDateFormat dateFormatter = new SimpleDateFormat("E, dd-MM-yyyy 'at' hh:mm:ss a z");
//System.out.println("Date & Time now: " + dateFormatter.format(now));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not necessary for your program to run, nor does it improve readability of your code.

return new CommandResult("Date & Time now: " + dateFormatter.format(now));
}
}