From 3d08a4e9a1fb2e9242d9d17fad122016bf234238 Mon Sep 17 00:00:00 2001 From: NIHAL T P Date: Sun, 12 Oct 2025 00:12:19 +0530 Subject: [PATCH] Add DateCommand to display the current date --- src/main/java/com/mycmd/App.java | 1 + src/main/java/com/mycmd/commands/DateCommand.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/main/java/com/mycmd/commands/DateCommand.java diff --git a/src/main/java/com/mycmd/App.java b/src/main/java/com/mycmd/App.java index 1458f14..e6c301a 100644 --- a/src/main/java/com/mycmd/App.java +++ b/src/main/java/com/mycmd/App.java @@ -51,5 +51,6 @@ private static void registerCommands(Map commands) { commands.put("help", new HelpCommand(commands)); commands.put("exit", new ExitCommand()); commands.put("ver", new VersionCommand()); + commands.put("date", new DateCommand()); } } diff --git a/src/main/java/com/mycmd/commands/DateCommand.java b/src/main/java/com/mycmd/commands/DateCommand.java new file mode 100644 index 0000000..33f6893 --- /dev/null +++ b/src/main/java/com/mycmd/commands/DateCommand.java @@ -0,0 +1,12 @@ +package com.mycmd.commands; + +import com.mycmd.Command; +import com.mycmd.ShellContext; +import java.time.LocalDate; + +public class DateCommand implements Command { + @Override + public void execute(String[] args, ShellContext context) { + System.out.println("The current date is: " + java.time.LocalDate.now()); + } +}