public static TimeDuration stringToTimeDuration(String duration) {
    { int nDays = 0;
      int nMillis = 0;
      boolean negativeP = Native.stringSearch(duration, "minus", 0) != Stella.NULL_INTEGER;
      int dayStartPosition = 0;
      int dayEndPosition = 0;
      int msStartPosition = 0;
      int msEndPosition = 0;

      if (negativeP) {
        dayStartPosition = 6;
      }
      else if (Native.stringSearch(duration, "plus", 0) != Stella.NULL_INTEGER) {
        dayStartPosition = 5;
      }
      else {
        dayStartPosition = 0;
      }
      dayEndPosition = Native.stringSearch(duration, "days", dayStartPosition);
      if (dayEndPosition == Stella.NULL_INTEGER) {
        return (null);
      }
      else {
        nDays = ((int)(Native.stringToInteger(Native.string_subsequence(duration, dayStartPosition, dayEndPosition - 1))));
      }
      msStartPosition = Native.string_position(duration, ' ', dayEndPosition);
      if (msStartPosition != Stella.NULL_INTEGER) {
        msEndPosition = Native.stringSearch(duration, "ms", msStartPosition);
        if (msEndPosition != Stella.NULL_INTEGER) {
          nMillis = ((int)(Native.stringToInteger(Native.string_subsequence(duration, msStartPosition + 1, msEndPosition - 1))));
        }
      }
      if (negativeP) {
        return (TimeDuration.makeTimeDuration(0 - nDays, 0 - nMillis));
      }
      else {
        return (TimeDuration.makeTimeDuration(nDays, nMillis));
      }
    }
  }