mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
07.00.2009 3d95b1667808dc87d7536e69f2e5b93cb2dbd6f9
opendj-sdk/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
@@ -43,6 +43,9 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -63,6 +66,7 @@
import org.opends.server.tools.ClientException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.PasswordReader;
import org.opends.server.util.SetupUtils;
/**
@@ -109,6 +113,16 @@
   */
  protected final static int CONFIRMATION_MAX_TRIES = 5;
  private static final String COMMENT_SHELL_UNIX = "# ";
  private static final String COMMENT_BATCH_WINDOWS = "rem ";
  /**
   * The String used to write comments in a shell (or batch) script.
   */
  protected static final String SHELL_COMMENT_SEPARATOR =
    SetupUtils.isWindows() ?
      COMMENT_BATCH_WINDOWS : COMMENT_SHELL_UNIX;
  /**
   * Creates a new console application instance.
   *
@@ -1011,4 +1025,36 @@
    }
    return ctx;
  }
  /**
   * Returns the message to be displayed in the file with the equivalent
   * command-line with information about the current time.
   * @return  the message to be displayed in the file with the equivalent
   * command-line with information about the current time.
   */
  protected String getCurrentOperationDateMessage()
  {
    String date = formatDateTimeStringForEquivalentCommand(new Date());
    return INFO_OPERATION_START_TIME_MESSAGE.get(date).
    toString();
  }
  /**
   * Formats a Date to String representation in "dd/MMM/yyyy:HH:mm:ss Z".
   *
   * @param date to format; null if <code>date</code> is null
   * @return string representation of the date
   */
  protected String formatDateTimeStringForEquivalentCommand(Date date)
  {
    String timeStr = null;
    if (date != null)
    {
      SimpleDateFormat dateFormat =
        new SimpleDateFormat(DATE_FORMAT_LOCAL_TIME);
      dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
      timeStr = dateFormat.format(date);
    }
    return timeStr;
  }
}