Add the following dependency
<dependency>
<groupId>org.kohsuke.args4j</groupId>
<artifactId>args4j-maven-plugin</artifactId>
<version>2.33</version>
</dependency>
In the main class add the following element
@Option(name = "-date", required = true, metaVar = "mmddyyyy", usage = "date for which we want this to happen")
private String date = null;
Within the main method add code to parse command line args and populate date
public static void main(String args[]){
try {
parser.parseArgument(args);
SimpleDateFormat commandLineDateFormat = new SimpleDateFormat("mmddyyyy", Locale.getDefault());
Date date = commandLineDateFormat.parse(date);
} catch (Exception ex){
ex.printStackTrace();
}
}
|