Luffy spent two years on the island. He spent a year and a half learning Haki, which means during that year and a half, he didn't have G4 since G4 works by controlling his retraction and propulsion through Haki. That means that after Rayleigh left and he was alone for 6 months, he had to fight the animals on the island, and Rayleigh said that at least 100 of them were stronger than Luffy. That means that after learning Haki, Luffy was left alone for 6 months on an island where at least 100 of the monster-sized animals were stronger than him. He said he needed G4 in order to fight the animals and survive on the island. That means that Luffy had and was using Gear 4 for at least 6 months to fight, as he would have to continuously fight the animals there in order to survive.