Inner method for elapsed time label formatting
@param elapsed the time in milliseconds
@return the label with the elapsed time in readable format
352555
private String getElapsedTimeLabel(long elapsed) {
        return (elapsed >= 0) ?
                String.format("%02d:%02d.%03d", elapsed / 60000, (elapsed % 60000) / 1000, (elapsed % 1000)) :
                null;
    }
717894
private Duration convertFormat(long totalTime, TimeUnit format)
   {
      double duration = totalTime;

      switch (format)
      {
         case MINUTES:
         case ELAPSED_MINUTES:
         {
            duration /= (60 * 1000);
            break;
         }

         case HOURS:
         case ELAPSED_HOURS:
         {
            duration /= (60 * 60 * 1000);
            break;
         }

         case DAYS:
         {
            double minutesPerDay = getMinutesPerDay();
            if (minutesPerDay != 0)
            {
               duration /= (minutesPerDay * 60 * 1000);
            }
            else
            {
               duration = 0;
            }
            break;
         }

         case WEEKS:
         {
            double minutesPerWeek = getMinutesPerWeek();
            if (minutesPerWeek != 0)
            {
               duration /= (minutesPerWeek * 60 * 1000);
            }
            else
            {
               duration = 0;
            }
            break;
         }

         case MONTHS:
         {
            double daysPerMonth = getParentFile().getProjectProperties().getDaysPerMonth().doubleValue();
            double minutesPerDay = getMinutesPerDay();
            if (daysPerMonth != 0 && minutesPerDay != 0)
            {
               duration /= (daysPerMonth * minutesPerDay * 60 * 1000);
            }
            else
            {
               duration = 0;
            }
            break;
         }

         case ELAPSED_DAYS:
         {
            duration /= (24 * 60 * 60 * 1000);
            break;
         }

         case ELAPSED_WEEKS:
         {
            duration /= (7 * 24 * 60 * 60 * 1000);
            break;
         }

         case ELAPSED_MONTHS:
         {
            duration /= (30 * 24 * 60 * 60 * 1000);
            break;
         }

         default:
         {
            throw new IllegalArgumentException("TimeUnit " + format + " not supported");
         }
      }

      return (Duration.getInstance(duration, format));
   }
151739
public com.google.protobuf.ByteString
      getTimelineLabelBytes() {
    java.lang.Object ref = timelineLabel_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      timelineLabel_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
649074
public static String getDuration(long diff) {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(new Date(diff));
        StringBuffer s = new StringBuffer();
        if (calendar.get(Calendar.HOUR) > 1) {
            s.append("hours: " + (calendar.get(Calendar.HOUR) - 1) + ", ");
        }
        if (calendar.get(Calendar.MINUTE) > 0) {
            s.append("minutes: " + (calendar.get(Calendar.MINUTE)) + ", ");
        }
        if (calendar.get(Calendar.SECOND) > 0) {
            s.append("seconds: " + (calendar.get(Calendar.SECOND)) + ", ");
        }
        if (calendar.get(Calendar.MILLISECOND) > 1) {
            s.append("milliseconds: " + (calendar.get(Calendar.MILLISECOND)) + ", ");
        }
        s.append("total milliseconds: " + diff);
        return s.toString();
    }
602337
public long getElapsedMilliseconds() {
		long elapsed;
		if (running) {
			elapsed = (System.nanoTime() - startTime);
		} else {
			elapsed = (stopTime - startTime);
		}
		return elapsed / nsPerMs;
	}
357440
@VisibleForTesting
    protected static String createLabelText(
            final DistanceUnit scaleUnit, final double value, final DistanceUnit intervalUnit) {
        double scaledValue = scaleUnit.convertTo(value, intervalUnit);

        // assume that there is no interval smaller then 0.0001
        scaledValue = Math.round(scaledValue * 10000) / 10000;
        String decimals = Double.toString(scaledValue).split("\\.")[1];

        if (Double.valueOf(decimals) == 0) {
            return Long.toString(Math.round(scaledValue));
        } else {
            return Double.toString(scaledValue);
        }
    }
770182
public LabelCache labels(String monitorId)
    {
        LabelCache cache = labels.get(monitorId);
        if(cache == null)
            labels.put(monitorId, cache = new LabelCache(monitorId));
        return cache;
    }
980016
public synchronized String nextLabel() {
        if (labels != null) {
            return labels.get(((Long) counter.getAndIncrement()).intValue());
        } else {
            maxCount = counter.getAndIncrement();
            return formatLabel(maxCount);
        }
    }
1037931
def create_time_labels(self):
        
        min_time = int(floor(min(self.data.axis['time'][0])))
        max_time = int(ceil(max(self.data.axis['time'][0])))
        n_time_labels = self.parent.value('n_time_labels')

        self.idx_time = []
        self.time_pos = []
        for one_time in linspace(min_time, max_time, n_time_labels):
            x_label = (self.data.start_time +
                       timedelta(seconds=one_time)).strftime('%H:%M:%S')
            item = QGraphicsSimpleTextItem(x_label)
            item.setFlag(QGraphicsItem.ItemIgnoresTransformations)
            self.idx_time.append(item)
            self.time_pos.append(QPointF(one_time,
                                         len(self.idx_label) *
                                         self.parent.value('y_distance')))
1239382
public static String toTimeUnit(long millis, int scale) {
		if (millis < MILLIS_PER_SECOND) {
			return String.format("%4dms", millis);
		}

		if (millis < MILLIS_PER_MINUTE) {
			return String.format("%" + (scale == 0 ? 2 : 3 + scale) + '.' + scale + "fs",
					millis * 1d / MILLIS_PER_SECOND);
		}

		if (millis < MILLIS_PER_HOUR) {
			return String.format("%" + (scale == 0 ? 2 : 3 + scale) + '.' + scale + "fm",
					millis * 1d / MILLIS_PER_MINUTE);
		}

		if (millis < MILLIS_PER_DAY) {
			return String.format("%" + (scale == 0 ? 2 : 3 + scale) + '.' + scale + "fh",
					millis * 1d / MILLIS_PER_HOUR);
		}

		return String.format("%" + (scale == 0 ? 2 : 3 + scale) + '.' + scale + "fd", millis * 1d / MILLIS_PER_DAY);
	}
1263659
private String getLabel(int i)
	{
		for (String label : labelMap.keySet())
		{
			if (labelMap.get(label) == i) return label;
		}
		return null;
	}
44824
public String getElapsedTimeString() {
        int elapsedSeconds = (int) (getElapsedTime() / 1000);

        if (elapsedSeconds == 0)
            return "0s";

        int minutes = elapsedSeconds / 60;
        elapsedSeconds -= (60 * minutes);

        if (minutes == 0) {
            return elapsedSeconds + "s";
        }

        return minutes + "m " + elapsedSeconds + "s";
    }
8302
public long getDurationMillis()
	{
		List<Element> durations = element.getChildren("Duration");

		if (durations.size() != 0)
		{
			final String durationString = durations.get(0).getValue();

			final long duration = Long.parseLong(durationString);

			return duration;
		}
		else
		{
			throw new RuntimeException("No Duration elements present on track!");
		}
	}
936040
private static String formatTime(int length, long time) {
        Calendar cal = Calendar.getInstance();
        if (time > -1) cal.setTimeInMillis(time);
        StringBuilder sb = new StringBuilder(length);
        int month = cal.get(Calendar.MONTH) + 1;
        int day = cal.get(Calendar.DAY_OF_MONTH);
        int hour = cal.get(Calendar.HOUR_OF_DAY);
        int minute = cal.get(Calendar.MINUTE);
        int seconds = cal.get(Calendar.SECOND);
        sb.append(cal.get(Calendar.YEAR)).append('-');
        if (month < 10) sb.append('0');
        sb.append(month).append('-');
        if (day < 10) sb.append('0');
        sb.append(day).append(' ');
        if (hour < 10) sb.append('0');
        sb.append(hour).append(':');
        if (minute < 10) sb.append('0');
        sb.append(minute).append(':');
        if (seconds < 10) sb.append('0');
        sb.append(seconds);
        if (length > 20) {
            int millis = cal.get(Calendar.MILLISECOND);
            sb.append('.');
            if (millis < 10) {
                sb.append("00");
            } else if (millis < 100) {
                sb.append('0');
            }
            sb.append(millis);
        }
        return sb.toString();
    }
201947
def elapsed():
    
    environ.abort_thread()
    step = _cd.project.get_internal_project().current_step
    r = _get_report()
    r.append_body(render.elapsed_time(step.elapsed_time))

    result = '[ELAPSED]: {}\n'.format(timedelta(seconds=step.elapsed_time))
    r.stdout_interceptor.write_source(result)
405025
private String formatTimeUnit(TimeUnit timeUnit)
   {
      int units = timeUnit.getValue();
      String result;
      String[][] unitNames = LocaleData.getStringArrays(m_locale, LocaleData.TIME_UNITS_ARRAY);

      if (units < 0 || units >= unitNames.length)
      {
         result = "";
      }
      else
      {
         result = unitNames[units][0];
      }

      return (result);
   }
652820
public static long parseTimeStamp(String fileName) {
        if (fileName == null || fileName.isEmpty()) {
            return -1L;
        }
        int pidIndex = fileName.indexOf(TIMESEPARATOR);
        int labelIndex = fileName.indexOf(LABELSEPARATOR);
        // If no time separator or it's a part of the label there's no timestamp
        if (pidIndex < 0 || (labelIndex > 0 && labelIndex < pidIndex)) {
            return -1L;
        }
        try {
            return Long.parseLong(fileName.substring(0, pidIndex));
        } catch (NumberFormatException ex) {
            return -1L;
        }
    }