*2 Before MARCUS, WILLIAM PRYOR and FAY, Circuit Judges.
PER CURIAM:
Gilberto Ivan Ramirez appeals the dismissal of his petition for review of the denial of his application for naturalization. He contends that the district court erred when it ruled that the date of his conviction for an aggravated felony rendered him permanently ineligible for naturalization. We affirm.
We review de novo a dismissal for failure to state a claim upon which relief may be granted. Leib v. Hillsborough Cnty. Pub. Transp. Comm’n , 558 F.3d 1301, 1305 (11th Cir. 2009).
To become a naturalized citizen, an applicant must establish and maintain “good moral character” while residing in the United States. 8 U.S.C. § 1427(a). An applicant cannot establish good moral character if he was convicted of an aggravated felony on or after November 29, 1990. 8 C.F.R. § 316.10(b)(1)(ii). Aggravated felonies include drug trafficking crimes. 8 U.S.C. § 1101(a)(43)(B). A conviction can be “a formal judgment of guilt of the alien entered by a court.” Id. § 1101(a)(48)(A). And “if adjudication of guilt has been withheld,” a conviction occurs when “(i) a judge or jury has found the alien guilty or the alien has entered a plea of guilty . . . and (ii) the judge has ordered some form of punishment, penalty, or restraint on the alien’s liberty to be imposed.” Id. § 1101(a)(48)(A)(i)–(ii).
The district court correctly concluded that Ramirez’s conviction for possession with intent to distribute at least five kilograms of cocaine occurred after November 29, 1990. Ramirez was not convicted until the district court accepted his plea, adjudicated his guilt, imposed his sentence, and entered its judgment in January 1991. Mejia Rodriguez v. Dep’t of Homeland Sec. , 629 F.3d 1223, 1226 (11th Cir. 2013). The detention order entered in June 1989 was not a punishment because it was unrelated to Ramirez’s guilt or innocence. The district court determined that Ramirez was a flight risk and a danger to the community and ordered him detained pending the outcome of his criminal case. We affirm.
AFFIRMED.
