Ejemplo n.º 1
0
  /**
   * private method to produce a time string from the indicated DTG we've moved it out of the
   * newTime box so that we can access it from a tester
   */
  public String getNewTime(final HiResDate DTG) {
    final String pattern = _dateFormatter.toPattern();

    String res = "";

    if (pattern.startsWith("'T+'")) {
      // hey, we're doing our "Special format".
      res = "T ";

      // get the T-zero time
      final HiResDate theTZero = getTimeZero();
      if (theTZero == null) {
        // no, return an error message
        return "N/A";
      }

      final long Tzero = theTZero.getMicros();

      // what's the elapsed time
      final long elapsed = DTG.getMicros() - Tzero;

      if (Math.abs(elapsed) > 1000000000000l) {
        res = "N/A";
      } else {

        // how many seconds is this?
        long secs = (long) (elapsed / 1000000d);

        // are we +ve?
        if (secs > 0) {
          res += "+";
        } else {
          res += "-";
        }

        // ok, we've handled the +ve/-ve make it absolute
        secs = Math.abs(secs);

        // which format do they want?
        String format = pattern.substring(pattern.indexOf(" "));

        // strip the format string
        format = format.trim();

        if (format.equals("SSS")) {
          // do we have our number formatter?
          if (_secondsFormat == null) _secondsFormat = new java.text.DecimalFormat("000s");

          res += _secondsFormat.format(secs);
        } else if (format.equals("MM:SS")) {
          // how many mins?
          final long mins = secs / 60;

          // and the seconds
          secs -= mins * 60;

          res += mins;

          res += ":";

          res += MWC.Utilities.TextFormatting.BriefFormatLocation.df2.format(secs);

        } else {
          MWC.Utilities.Errors.Trace.trace("Step control: invalid TZero format found:" + format);
        }
      }
    } else {
      // are we in hi-res mode or not?
      if (HiResDate.inHiResProcessingMode()) res = DebriefFormatDateTime.formatMicros(DTG);
      else res = _dateFormatter.format(DTG.getDate());
    }

    return res;
  }
Ejemplo n.º 2
0
 public final String getDateFormat() {
   return _dateFormatter.toPattern();
 }