SAN FRANCISCO — California companies must pay overtime to nonresidents who spend time working in the state, the state Supreme Court ruled today.

Answering a certified question for the Ninth Circuit U.S. Court of Appeals, the justices ruled 7-0 that travelling software trainers employed by Oracle Corp. are covered by the state’s wage-and-hour laws on days that they are working here.