Method 1: Sony Xperia Z Format Disposal

Enter the Settings section of your phone.
Enter Located Backup and Reset section in the Settings section.
Select Factory data reset. Music, pictures, and other user selects the option to delete the built-in storage for cleaning the data.
Tap the button reset the phone. Now you will begin to format the phone and will be opened after a while.

Method 2: Sony Xperia Z Format Disposal

Situated on the phone's power button, remove the cover of the microSD and SIM card slots.
According to the model of your phone Yellow, Red, you will see a small orange button.
Press this button with a pen or a pinhead and wait 10 seconds.
Your phone will vibrate and will shut down.
You can turn on your phone, press the phone's power button.
Your phone will open in a formatted manner.