In James' times there were 3 main indicators of external wealth.
He uses 3 terms to point out the short-lived nature of each one.
First, there was grain- (James 5:2) but he talks about riches rotting, or spoiling.
Second, there was clothing- it was considered wealth to have more than the clothing on your back at that point in time. James' echoes Jesus that clothes are subject to the ruin of moths (Matt 6:19).
Lastly, gold and silver- James knew that these metals were not subject to literal rust but uses irony to make the point that when God brings judgement even these precious metals will be doomed to corruption.
When James (5:3) says, “It is in the last days you have stored up your treasure,” he is referring to the entire period between Christ’s ascension and second coming, which is viewed as “the last days” (Acts 2:17; 2 Timothy 3:1, Hebrews 1:2). But death is “the last day” for all of us! As the rich fool in Jesus’ parable found out, he had plenty stored up for this life, but when he died, he was poor where it mattered most—he was not rich toward God (Luke12:16-21).
To be rich without God is to be short-sighted in light of eternity.