forked from Drive-for-Java/MyCMD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateCommand.java
More file actions
35 lines (31 loc) · 1023 Bytes
/
Copy pathDateCommand.java
File metadata and controls
35 lines (31 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.mycmd.commands;
import com.mycmd.Command;
import com.mycmd.ShellContext;
import java.time.LocalDate;
/**
* Command that prints the current date to standard output.
*
* <p>This command does not use the provided {@link ShellContext} but keeps the
* parameter to conform to the {@link Command} contract. The output is produced
* using {@link LocalDate#now()} and printed in ISO-8601 format (yyyy-MM-dd).</p>
*/
public class DateCommand implements Command {
/**
* Print the current date.
*
* @param args ignored for this command; may be empty or contain unused tokens.
* @param context the current shell context; not used by this command.
*/
@Override
public void execute(String[] args, ShellContext context) {
System.out.println("The current date is: " + java.time.LocalDate.now());
}
@Override
public String description() {
return "Display current date.";
}
@Override
public String usage() {
return "date";
}
}