Parses a duration string.
@param value the duration string (e.g. "P30DT10H")
@return the parsed duration
@throws IllegalArgumentException if the duration string is invalid
423210
public static Duration parse(String value) {
		/*
		 * Implementation note: Regular expressions are not used to improve
		 * performance.
		 */

		if (value.length() == 0) {
			throw parseError(value);
		}

		int index = 0;
		char first = value.charAt(index);
		boolean prior = (first == '-');
		if (first == '-' || first == '+') {
			index++;
		}

		if (value.charAt(index) != 'P') {
			throw parseError(value);
		}

		Builder builder = new Builder();
		builder.prior(prior);

		StringBuilder buffer = new StringBuilder();
		for (int i = index + 1; i < value.length(); i++) {
			char c = value.charAt(i);

			if (c == 'T') {
				/*
				 * A "T" character is supposed to immediately precede the time
				 * component value(s). It is required by the syntax, but not
				 * really necessary. Ignore it.
				 */
				continue;
			}

			if (c >= '0' && c <= '9') {
				buffer.append(c);
				continue;
			}

			if (buffer.length() == 0) {
				throw parseError(value);
			}

			Integer num = Integer.valueOf(buffer.toString());
			buffer.setLength(0);

			switch (c) {
			case 'W':
				builder.weeks(num);
				break;
			case 'D':
				builder.days(num);
				break;
			case 'H':
				builder.hours(num);
				break;
			case 'M':
				builder.minutes(num);
				break;
			case 'S':
				builder.seconds(num);
				break;
			default:
				throw parseError(value);
			}
		}

		return builder.build();
	}
126584
private static function _parseDateString($value)
    {
        $result = @preg_match('/^\d\d\d\d-\d?\d-\d?\d$/', $value);
        if ($result !== 1)
            return null;
        $timestamp = strtotime($value);
        if ($timestamp === false)
            return null;

        return $timestamp;
    }
1365603
public static final Rate parseRate(BigDecimal value)
   {
      Rate result = null;

      if (value != null)
      {
         result = new Rate(value, TimeUnit.HOURS);
      }

      return (result);
   }
596902
public static MutableTimecodeDuration valueOf(String timecode) throws IllegalArgumentException
    {
        MutableTimecodeDuration td = new MutableTimecodeDuration();
        return (MutableTimecodeDuration) td.parse(timecode);
    }
770905
@Override
	protected R parseValueFromString(String value)
	{


        value = value.replaceAll("-", "_");
        value = value.replaceAll("^\\s+","");
        value = value.replaceAll("\\s+$","");
		return (R)Enum.valueOf(this.getRange(), value);
	}
482980
private static QName getDurationType(Duration value) {
        boolean hasYearMonth = (
                value.isSet(DatatypeConstants.YEARS)  ||
                value.isSet(DatatypeConstants.MONTHS)
                );
        boolean hasDayTime = (
                value.isSet(DatatypeConstants.DAYS)    ||
                value.isSet(DatatypeConstants.HOURS)   ||
                value.isSet(DatatypeConstants.MINUTES) ||
                value.isSet(DatatypeConstants.SECONDS)
                );

        if (hasYearMonth && !hasDayTime) {
            return DatatypeConstants.DURATION_YEARMONTH;
        } else if ((!hasYearMonth) && hasDayTime) {
            return DatatypeConstants.DURATION_DAYTIME;
        }

        throw new IllegalArgumentException("value must be yearMonthDuration or dayTimeDuration: "+value);
    }
708694
public static TimecodeDuration valueOf(String timecode) throws IllegalArgumentException
    {
        TimecodeDuration td = new TimecodeDuration();
        return (TimecodeDuration) td.parse(timecode);
    }
906261
public static String duration(final Number value)
    {
        // NOTE: does not support any other locale
        return withinLocale(new Callable<String>()
        {
            public String call() throws Exception
            {
                return context.get().getRuleBasedNumberFormat(RuleBasedNumberFormat.DURATION).format(value);
            }
        }, Locale.ENGLISH);
    }
811926
public static boolean isLongValue(final String value) {
        try {
            Long.parseLong(value);
            return true;
        } catch (final NumberFormatException ex) {
            return false;
        }
    }
172601
static long parseDuration(String key, @Nullable String value) {
    requireArgument((value != null) && !value.isEmpty(), "value of key %s omitted", key);
    @SuppressWarnings("NullAway")
    String duration = value.substring(0, value.length() - 1);
    return parseLong(key, duration);
  }
392533
public static java.sql.Time getTime(Object value) {
        try {
            return toTime(value);
        } catch (ParseException pe) {
            pe.printStackTrace();
            return null;
        }
    }
733751
private static function _parseDateTimeString($value)
    {
        $result = @preg_match('/^\d\d\d\d-\d?\d-\d?\d \d\d:\d\d:\d\d$/', $value);
        if ($result !== 1)
            return null;
        $timestamp = strtotime($value);
        if ($timestamp === false)
            return null;

        return $timestamp;
    }
304102
public static int parseSeconds(String value, int defaultValue) {
    try {
      long seconds = Long.parseLong(value);
      if (seconds > Integer.MAX_VALUE) {
        return Integer.MAX_VALUE;
      } else if (seconds < 0) {
        return 0;
      } else {
        return (int) seconds;
      }
    } catch (NumberFormatException e) {
      return defaultValue;
    }
  }
189884
public static Integer parseInteger(String value) throws ParseException
   {
      Integer result = null;

      if (value.length() > 0 && value.indexOf(' ') == -1)
      {
         if (value.indexOf('.') == -1)
         {
            result = Integer.valueOf(value);
         }
         else
         {
            Number n = DatatypeConverter.parseDouble(value);
            result = Integer.valueOf(n.intValue());
         }
      }

      return result;
   }
970966
public void setFMDate(String value) {
        final long multiplier = 100000000;
        Calendar cal = Calendar.getInstance();
        double val = Double.parseDouble(value);
        
        if (val < 1000000D || val > 9999999D) {
            throw new IllegalArgumentException();
        }
        
        long date = (long) Math.floor(val * multiplier);
        hasTime = date % multiplier != 0;
        date = setCalendar(cal, Calendar.MILLISECOND, date, 100);
        date = setCalendar(cal, Calendar.SECOND, date, 100);
        date = setCalendar(cal, Calendar.MINUTE, date, 100);
        date = setCalendar(cal, Calendar.HOUR_OF_DAY, date, 100);
        date = setCalendar(cal, Calendar.DAY_OF_MONTH, date, 100);
        date = setCalendar(cal, Calendar.MONTH, date - 1, 100);
        date = setCalendar(cal, Calendar.YEAR, date + 1700, 10000);
        setTime(cal.getTimeInMillis());
    }
224523
public static long parseDuration(CharSequence duration)
    {
        // Match the duration against the regular expression.
        Matcher matcher = DURATION_PATTERN.matcher(duration);

        // Check that the argument is of the right format accepted by this method.
        if (!matcher.matches())
        {
            throw new IllegalArgumentException("The duration definition is not in the correct format.");
        }

        // This accumulates the duration.
        long result = 0;

        int numGroups = matcher.groupCount();

        // Extract the days.
        if (numGroups >= 1)
        {
            String daysString = matcher.group(1);
            result +=
                (daysString == null)
                ? 0 : (Long.parseLong(daysString.substring(0, daysString.length() - 1)) * 24 * 60 * 60 * 1000);
        }

        // Extract the hours.
        if (numGroups >= 2)
        {
            String hoursString = matcher.group(2);
            result +=
                (hoursString == null)
                ? 0 : (Long.parseLong(hoursString.substring(0, hoursString.length() - 1)) * 60 * 60 * 1000);
        }

        // Extract the minutes.
        if (numGroups >= 3)
        {
            String minutesString = matcher.group(3);
            result +=
                (minutesString == null)
                ? 0 : (Long.parseLong(minutesString.substring(0, minutesString.length() - 1)) * 60 * 1000);
        }

        // Extract the seconds.
        if (numGroups >= 4)
        {
            String secondsString = matcher.group(4);
            result +=
                (secondsString == null)
                ? 0 : (Long.parseLong(secondsString.substring(0, secondsString.length() - 1)) * 1000);
        }

        return result;
    }
703186
private BigInteger printExtendedAttributeDurationFormat(Object value)
   {
      BigInteger result = null;
      if (value instanceof Duration)
      {
         result = DatatypeConverter.printDurationTimeUnits(((Duration) value).getUnits(), false);
      }
      return (result);
   }