Years? I am not sure why a composite filling would be used as a "temporary filling", unless you cannot afford a more permanent restoration at this time. Composite fillings are generally used as permanent fillings and can last for years. Some of mine are still in place and functioning after 10 years or more. However, they have no specific lifespan, especially under less than ideal conditions.
Rephrase question. There is no such thing as a temporary "composite " filling, you need too clear this with your office, composite flings are like silver fillings they are regular fillings, when done right they should last at least 5 years. They are indication for when you can get a temporary filling for a few weeks while preparing the permanent one or waiting for a root canal.
Up to 4 weeks. Your dentist wants to wait a short period of time for the tooth to heal.
Not usual treatment. Composites are only temporary in specific instances. Maybe, it is used to seal the opening of a root canal tooth, or it is used as a build up in lieu of a necessary crown restoration. In any case, please ask your dentist when you should have a permanent restoration placed. Take care...