If the appeal in such case is dismissed or the conviction is affirmed on hearing, such judgment shall be executed by the court by which it was rendered on receipt of the mandate of the appellate court. A defendant who was not admitted to bail during the time the appeal was pending shall receive credit against the sentence for all of the time he or she was incarcerated while the appeal was pending.