public static long parseXsDuration(String value){
  Matcher matcher=XS_DURATION_PATTERN.matcher(value);
  if (matcher.matches()) {
    boolean negated=!TextUtils.isEmpty(matcher.group(1));
    String years=matcher.group(3);
    double durationSeconds=(years != null) ? Double.parseDouble(years) * 31556908 : 0;
    String months=matcher.group(5);
    durationSeconds+=(months != null) ? Double.parseDouble(months) * 2629739 : 0;
    String days=matcher.group(7);
    durationSeconds+=(days != null) ? Double.parseDouble(days) * 86400 : 0;
    String hours=matcher.group(10);
    durationSeconds+=(hours != null) ? Double.parseDouble(hours) * 3600 : 0;
    String minutes=matcher.group(12);
    durationSeconds+=(minutes != null) ? Double.parseDouble(minutes) * 60 : 0;
    String seconds=matcher.group(14);
    durationSeconds+=(seconds != null) ? Double.parseDouble(seconds) : 0;
    long durationMillis=(long)(durationSeconds * 1000);
    return negated ? -durationMillis : durationMillis;
  }
 else {
    return (long)(Double.parseDouble(value) * 3600 * 1000);
  }
}

public static long parseXsDuration ( String value ) { Matcher matcher = XS_DURATION_PATTERN . matcher ( value ) ; if ( matcher . matches ( ) ) { boolean negated = ! TextUtils . isEmpty ( matcher . group ( 1 ) ) ; String years = matcher . group ( 3 ) ; double durationSeconds = ( years != null ) ? Double . parseDouble ( years ) * 31556908 : 0 ; String months = matcher . group ( 5 ) ; durationSeconds += ( months != null ) ? Double . parseDouble ( months ) * 2629739 : 0 ; String days = matcher . group ( 7 ) ; durationSeconds += ( days != null ) ? Double . parseDouble ( days ) * 86400 : 0 ; String hours = matcher . group ( 10 ) ; durationSeconds += ( hours != null ) ? Double . parseDouble ( hours ) * 3600 : 0 ; String minutes = matcher . group ( 12 ) ; durationSeconds += ( minutes != null ) ? Double . parseDouble ( minutes ) * 60 : 0 ; String seconds = matcher . group ( 14 ) ; durationSeconds += ( seconds != null ) ? Double . parseDouble ( seconds ) : 0 ; long durationMillis = ( long ) ( durationSeconds * 1000 ) ; return negated ? - durationMillis : durationMillis ; } else { return ( long ) ( Double . parseDouble ( value ) * 3600 * 1000 ) ; } }
parses an xs : duration attribute value , returning the parsed duration in milliseconds .
