RICHMOND — With their trial on public corruption charges less than three weeks away, former Virginia Governor Robert F. McDonnell and his wife appeared in federal court here for more than an hour Thursday as their attorneys sought to convince a judge to let them use a high-priced legal expert as a witness for their defense.

The lengthy hearing put attorney Peter H. White, a former federal prosecutor now at the Schulte Roth & Zabel firm, in the unusual position of sitting in the witness chair while other lawyers grilled him about his credentials. Federal District Judge James Spencer did not immediately rule on whether White could testify as an expert at the trial, but said he would do so “very, very quickly.”

The McDonnells were charged in January in a 14-count indictment that alleges they lent the prestige of the governor’s office to Richmond businessman Jonnie R. Williams Sr. and a dietary supplement company he used to run, and in exchange, Williams lavished them with gifts and money. The lengthy hearing Thursday provided yet another indication that the McDonnells intend to aggressively attack Williams’s credibility as a key part of their defense.

White’s testimony would give them another weapon to do that — albeit in a complicated and nuanced way. And even if it is allowed, it will not come cheap. White testified that he is billing the McDonnells at his standard rate of $940 an hour.

The McDonnells’ defense attorneys want White to be able to testify that Williams received a significant benefit when the government successfully sought a delay in two civil lawsuits against the dietary supplement company he used to run. That benefit — plus an immunity agreement from criminal prosecution on securities and public corruption charges — undermines Williams’s credibility on the witness stand, defense attorneys have argued.

But prosecutors argued that White’s opinion was unscientific and, in many ways, flawed. And even the federal judge who will ultimately determine whether to allow White to testify questioned how the lawyer could quantify the benefit he claims Williams received.

Defense attorneys had already objected — unsuccessfully — after prosecutors won a stay in two civil lawsuits that shareholders filed against Williams and his company. They argued then that prosecutors were unfairly keeping a lid on unflattering evidence that might come out about their key witness as part of the suits.

Now, though, they want White to be able to tell jurors that if he were Williams’s defense attorney, he would have wanted those civil cases to be delayed.

A delay, White testified Thursday, would save Williams and the company money millions of dollars because they would be spared, at least temporarily, from producing voluminous documents and other evidence. And resolving the criminal case before the civil suits would be beneficial to Williams because it would remove the “uncertainty” that would come with all the cases proceeding at the same time.

Prosecutors noted, though, that Williams’s former company — or its insurance provider — would likely bear the costs associated with a civil lawsuit, so a delay would not help him personally. They also noted that if Williams testified in the criminal case first, that testimony could possibly be used against him in the civil suits — a potential disadvantage.

Assistant U.S. Attorney Michael Dry argued the trial would devolve into a “sideshow” about insurance and billing were White to be allowed to testify.

Spencer questioned how White could put a figure on the benefit Williams received, and White acknowledged it would be disingenuous to do so. The McDonnells’ defense attorneys argued, though, that even if White did not present an exact dollar figure, it would be important for him to explain to jurors the benefit that would not be immediately obvious to the average person.

McDonnell’s defense attorney declined to comment after the hearing. As he left the courthouse, McDonnell himself told a row of reporters it had been a “good afternoon” but offered no other comments as he and his wife got into a waiting car.