Skip to content

Commit 3d08a4e

Browse files
committed
Add DateCommand to display the current date
1 parent 15887b0 commit 3d08a4e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main/java/com/mycmd/App.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ private static void registerCommands(Map<String, Command> commands) {
5151
commands.put("help", new HelpCommand(commands));
5252
commands.put("exit", new ExitCommand());
5353
commands.put("ver", new VersionCommand());
54+
commands.put("date", new DateCommand());
5455
}
5556
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.mycmd.commands;
2+
3+
import com.mycmd.Command;
4+
import com.mycmd.ShellContext;
5+
import java.time.LocalDate;
6+
7+
public class DateCommand implements Command {
8+
@Override
9+
public void execute(String[] args, ShellContext context) {
10+
System.out.println("The current date is: " + java.time.LocalDate.now());
11+
}
12+
}

0 commit comments

Comments
 (0)