might be simpler to let TaskAttemptID parse it. In Elephant-bird, I do : 

     new TaskAttemptID(TaskID.forName("task_201305011733_0001_r_000001"), 2)