code: 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();
  	}
docs: Parses a duration string.
  @param value the duration string (e.g. "P30DT10H")
  @return the parsed duration
  @throws IllegalArgumentException if the duration string is invalid