Java Date Format in "args"

2k views Asked by At

So, I'm using JD-GUI to decompile some Java class files which doesn't have any documentation. This Java Application is running on a Windows Server and running via taskscheduler with a cmd file (I don't know exactly what, intern here).

If some one who worked with an args command can help me out, I would really appreciate it. The code snipped is attached, all what I want is to understand is what the for loop is doing at the end of the code.

public class Main
{
 public static void main(String[] args)
  {
  try
  {
  List violationList = new ArrayList();

  Calendar cal = Calendar.getInstance();
  Date inputDate = new Date();
  cal.setTime(inputDate);
  cal.set(11, 0);
  cal.set(12, 0);
  cal.set(13, 1);

  inputDate = cal.getTime();

  SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy");
  for (int ii = 0; ii < args.length; ii++) {
    if (args[ii].equals("-date")) {
      inputDate = dateFormat.parse(args[(ii + 1)]);
    }
 }

Here is the run.cmd file along with Java files I found. Notice there is .Main mention at the last line, something to do with those %1 and %2.

RUN.CMD

@ECHO OFF
set CP=.;realapplication.jar; commons-       logging.jar;msbase.jar;mail.jar;activation.jar;log4j.jar;
set CP=%CP%sqljdbc4.jar;msutil.jar;spring-1.2.6.jar;commons-httpclient-2.0.1.jar;weblogic_8.1.jar;
set CP=%CP%zipfilemanager.jar;kmoscommon.jar;sessionpool.jar;kmosdao.jar;gendao.jar;rowset-1.0.1.jar;
java -classpath "%CP%" com.adnan.Main %1 %2
1

There are 1 answers

1
Mureinik On BEST ANSWER

This for loop goes over the command line arguments and searches for a pair of arguments in the form of -date 16/11/81 (the given date is just an example, of course). Once it finds it, it parses the second argument (16/11/81, in this case) to a java.util.Date object and stores it in the inputDate variable. If the -date argument is omitted, today's date will be used.