COMMERCE, Calif. — With two weeks before California’s delegate-rich primary, Hillary Clinton stopped here on Tuesday and went on the attack against a rival. Just not the one she is currently running against.

Mrs. Clinton and Senator Bernie Sanders of Vermont each courted voters in California, which has more delegates to divvy up than any other state, but their appearances showed how differently they are approaching the coming contest. Both have harshly criticized Donald J. Trump, the presumptive Republican presidential nominee, but while Mrs. Clinton has made him her main focus, Mr. Sanders’s hopes are centered on an upset victory in the primary.

California, the nation’s most populous state, would be a prize for Mr. Sanders, who is hoping for a marquee victory that he could showcase heading into the party’s summer convention in Philadelphia. But however lustrous a victory might be, it would be largely symbolic given Mrs. Clinton’s nearly insurmountable delegate lead, and she is spending her time building a case against Mr. Trump.

At a rally in Los Angeles County, Mrs. Clinton continued to try out different attacks against the billionaire businessman, touching on subjects including his business acumen, his foreign policy views and even his reality-show catchphrase.