code: private int readComponent(String duration, int index, int length)
     {
        char c = 0;
        StringBuilder number = new StringBuilder();
  
        while (index < length)
        {
           c = duration.charAt(index);
           if (Character.isDigit(c) == true || c == '.')
           {
              number.append(c);
           }
           else
           {
              break;
           }
  
           ++index;
        }
  
        switch (c)
        {
           case 'Y':
           {
              m_years = Integer.parseInt(number.toString());
              break;
           }
  
           case 'M':
           {
              if (m_hasTime == false)
              {
                 m_months = Integer.parseInt(number.toString());
              }
              else
              {
                 m_minutes = Integer.parseInt(number.toString());
              }
              break;
           }
  
           case 'D':
           {
              m_days = Integer.parseInt(number.toString());
              break;
           }
  
           case 'T':
           {
              m_hasTime = true;
              break;
           }
  
           case 'H':
           {
              m_hours = Integer.parseInt(number.toString());
              break;
           }
  
           case 'S':
           {
              m_seconds = Double.parseDouble(number.toString());
              break;
           }
  
           default:
           {
              throw new IllegalArgumentException(duration);
           }
        }
  
        ++index;
  
        return (index);
     }
docs: This method is called repeatedly to parse each duration component
  from sorting data in xsd:duration format. Each component consists
  of a number, followed by a letter representing the type.
  
  @param duration xsd:duration formatted string
  @param index current position in the string
  @param length length of string
  @return current position in the string