A caterpillar does not hatch from a cocoon but from an egg. A moth hatches from a cocoon or pupa. The time spent in the cocoon varies from 10 days to seven years or more depending on the species.
Moths and butterflies go through a four-stage life cycle to complete metamorphosis. The stages include egg, larva, pupa and adult. Once a moth has mated, it deposits the eggs where the larva or caterpillar can find food. The caterpillar grows and enters the pupal stage, where it begins the transformation into a moth. After a time, the moth hatches and begins the cycle again.