
105 S.W.3d 915 (2003)
Roy M. MONROE, Appellant,
v.
MISSOURI DEPARTMENT OF CORRECTIONS, Respondent.
No. WD 61557.
Missouri Court of Appeals, Western District.
June 3, 2003.
*916 Craig Allan Johnston, Columbia, for appellant.
Jeremiah W. (Jay) Nixon, Atty. Gen., Andrew W. Hassell, Jefferson City, for respondent.
Before RONALD R. HOLLIGER, P.J., PAUL M. SPINDEN, and JAMES M. SMART, JR., JJ.
JAMES M. SMART, JR., Judge.
Roy M. Monroe appeals the circuit court's dismissal of his petition for declaratory judgment seeking jail time credit under section 558.031, RSMo 2000. The petition was dismissed for failure to state a claim upon which relief could be granted. The judgment is affirmed in part and reversed in part.


*917 Factual and Procedural Background
Monroe filed a petition for declaratory judgment in the Cole County Circuit Court on January 11, 2002, requesting a declaration that, pursuant to section 558.031, the Department of Corrections ("Department") should give him credit for time served between November 2, 1999 and December 28, 1999, and between January 3, 2000 and February 8, 2001, while he was awaiting disposition of forgery charges.[1]
In reviewing a dismissal for failure to state a claim upon which relief could be granted, this court deems the facts pleaded in the petition to be true. Roy v. Mo. Dep't of Corr., 23 S.W.3d 738, 741 (Mo. App.2000). Monroe's petition, summarized and incorporating the exhibits, alleged the following facts:
November 28, 1998Monroe was released on parole after serving twenty months of a five-year sentence for driving while intoxicated.
October 1999Monroe arrested for forgery and for assault 3rd degree (separate incidents).
November 1, 1999violation report was filed by parole officer alleging (1) law violations by forgery offenses and by assault 3rd degree, (2) violation of requirement to notify of change in residence, (3) violation of requirement to report in to officer and to attend out-patient drug treatment.
November 1, 1999arrest order was issued by Department of Corrections indicating charges that Monroe had violated condition # 1 of his parole (no new law violations); # 3 (residency notification); # 8 (reporting directives); and # 10 (special condition with regard to intoxicating beverages).
November 2, 1999Monroe apprehended; Parole officer recommended revocation of parole due to Monroe's arrest on three counts of forgery, failure to report change of residence, and failure to comply with reporting requirements and directives.
November 18, 1999Preliminary hearing conducted regarding Monroe's reported violations. Probable cause found and recommendation that parole be revoked because of forgery violations. Probable cause not found as to violation of condition # 3 (residency notification) and condition # 8 (failure to report in and to comply with directives).
December 28, 1999Monroe released.
January 3, 2000Monroe rearrested and returned to Department of Corrections.
February 2, 2000preliminary hearing. Board of Probation and Parole considered assault 3rd; the new DWI charge; and the forgery charge. Board also considered the failure to notify of change in residency and failure to follow directives, and failure to report in as directed. Probable cause was found as to forgery, mew DWI charge, and new assault 3rd degree charge.
March 31, 2000Final parole revocation hearing.
April 10, 2000Board issued order of revocation, relying on violation of conditions # 3, # 8, and # 10. The order did not mention the forgery charges.
February 8, 2001Monroe pleads guilty to forgery charges and Monroe sentenced for forgery violations (three *918 three-year sentences concurrent with each other and all existing cases).
Monroe asserted that the Department refused to allow him credit for the time served between November 2, 1999, and February 8, 2001, as to his sentence on the forgery charges. Monroe sought declaratory judgment crediting him with that time, as provided in section 558.031, or in the alternative, to hold an evidentiary hearing on the matter.
The Department filed a motion to dismiss, claiming that the petition failed to state a claim upon which relief could be granted. The trial court held a hearing and granted the motion to dismiss on May 13, 2002. Monroe appeals.

Argument
Monroe claims the trial court erred in dismissing his declaratory judgment action. Monroe asserts that his petition averred a justiciable issue in controversy between himself and the Department because he sufficiently pleaded that he was entitled to credit for time served, under section 558.031, while awaiting disposition of his forgery charges, in that his incarceration as a result of his parole revocation was "related to" his incarceration on the forgery charges.

Standard of Review
The standard of review to be applied when a petition has been dismissed for failure to state a claim upon which relief can be granted is found in Nazeri v. Missouri Valley Coll., 860 S.W.2d 303, 306 (Mo. banc 1993):
A motion to dismiss for failure to state a cause of action is solely a test of the adequacy of the plaintiff's petition. It assumes that all of plaintiff's averments are true, and liberally grants to plaintiff all reasonable inferences therefrom. No attempt is made to weigh any facts alleged as to whether they are credible or persuasive. Instead, the petition is reviewed in an almost academic manner, to determine if the facts alleged meet the elements of a recognized cause of action, or of a cause that might be adopted in that case. (Citations omitted.)
In reviewing the dismissal of declaratory judgment action for failure to state a claim, this court deems all well-pleaded facts to be true and determines whether they invoke principles of substantive law that would entitle the petitioner to relief. Sandy v. Schriro, 39 S.W.3d 853, 855 (Mo.App.2001). If so, then the petition is sufficient and cannot be dismissed for failure to state a claim. Id. If the petition contains facts supporting its allegations, and not mere conclusions, and those facts demonstrate a "justiciable controversy," the dismissal will be reversed and the cause remanded for a determination of the parties' rights. Id.

Petition for Declaratory Judgment
Monroe pleaded that he was claiming credit for time served in the Department of Corrections while awaiting disposition on the forgery charges in Morgan County as required by section 558.031 RSMo. He sought credit for the time from November 2, 1999, to February 8, 2001. Monroe's petition sets out the applicable statute, section 558.031, and analogized his case to the Missouri Supreme Court case, Goings v. Missouri Department of Corrections, 6 S.W.3d 906 (Mo. banc 1999). His pleading referred to Goings and states that Jennifer Crow, Records Officer for the Western Missouri Correctional Center, stated that he "is not entitled to the time credit requested because he was not revoked for # 1 laws, but # 3, # 8, and # 10" and that Goings, supra, does not apply. Monroe's petition challenges this conclusion because:

*919 ... [T]he violation reports and recommendations found in Exhibits A, B, C, D, G, H and J all relate to Movant's arrest for the forgery charges.... Also, the response to Movant's request for preliminary hearing on the parole violation reports dated November 15, 1999, and January 31, 2000, both reflect, among others, that the charges brought against Movant are related to the felony offenses of forgery.
If the Board of Probation and Parole [found] that Movant did not violate # 1 laws for his felony forgery arrest it could only be for reasons to penalize Movant. The facts support otherwise....
* * * *
Wherefore, Movant requests that an order be entered for declaratory judgment crediting him with the time served in the Department of Corrections between November 2, 1999, and February 8, 2001, toward his sentence in Morgan County case number CR900-2F as provided in § 558.031 or in the alternative, Movant requests an evidentiary hearing in this cause. [Exhibit references omitted.]
Although Monroe specifically requested the trial court to declare that he is entitled to jail time credit for the relevant time periods, the court concluded from the pleadings that Monroe was actually asking for a declaration that the Board's stated reasons for his parole revocation were not the true reasons. The court declined to do so. The trial court's order explains its reasoning for dismissing the petition:
The Missouri Board of Probation and Parole's (sic) revoked plaintiff's parole stating in its order of revocation that the basis for the revocation was plaintiff's failure to notify his parole officer of a change in residency within forty-eight hours; failure to abide by the directives of his parole officer; and for entering an establishment where intoxicating beverages was (sic) the major item offered for sale and consuming intoxicating beverages. Plaintiff requests this Court to declare that despite the Board's order, the real reason of revoking plaintiff's parole was his arrest for forgery and assault in the third degree. Because plaintiff requests this court to declare that the board's reason for revoking plaintiff's parole for something other than what was listed in the Board's order, plaintiff fails to state a claim for which relief can be granted.

Section 558.031 and Goings

Monroe bases his claim on section 558.031.1, RSMo 2000,[2] which provides that a "person shall receive credit toward the service of a sentence of imprisonment for all time in prison, jail or custody after *920 the offense occurred and before the commencement of the sentence, when the time in custody was related to that offense." Subsections (1), (2), and (3), of that section set forth exceptions for when credit will not be given. None of those exceptions are applicable to this case.
In Goings v. Missouri Department of Corrections, 6 S.W.3d 906 (Mo. banc 1999), the Missouri Supreme Court interpreted the phrase, "when the time in custody was related to that offense," in Section 558.031.1, to mean that time spent in prison following a parole revocation and previous to a new sentence is "related to" the new sentence when the offense underlying the new sentence was the reason for the parole revocation and the reason for the inmate's detention. Id. at 908. See State ex rel. Nixon v. Kelly, 58 S.W.3d 513, 519 (Mo. banc 2001).
Goings filed a declaratory judgment action, asserting that he was entitled to have the time spent in prison as a result of his parole revocation on the original charge credited toward his subsequent sentence on the new charge. Goings, 6 S.W.3d at 907. The Court found that Goings' time in custody was sufficiently "related to" the new offense because the reason he was taken into custody was his arrest on the new offense. Goings was granted the statutory credit. Id. at 907-08.
Monroe contends that his case is analogous to Goings in that the reason his parole was revoked on the DWI (the previous charge) was because of his arrest on the forgery charges, for which he was then sentenced. On November 1, 1999, an order of arrest was issued indicating that Monroe had violated, among others, condition # 1, which relates to the violation of laws. On that same date, a field violation report filed by a parole officer recommended that Monroe be arrested and that his parole be revoked, in part due to his arrest for the three counts of forgery (condition # 1). On November 2, 1999, Monroe was arrested on the parole warrant and returned to the Department of Corrections.
On November 18, 1999, a hearing was held at which probable cause to revoke Monroe's parole was found based on Monroe's arrest for forgery, a violation of condition # 1 of his parole agreement. The report from that hearing specifically stated that "no clear & convincing evidence of violations of conditions numbers 3 [failure to notify of change in residency] & 8 [failure to report as directed] was found." Thus, the hearing report focused specifically on the forgery as the basis of revocation.
A little over a month later, on December 28, 1999, Monroe was released from the Department's custody on December 28, 1999. There is nothing in the record at this point indicating why he was released from custody. Monroe was again arrested on a parole warrant about a week later on January 3, 2000, and returned to the Department, where he remained in custody.
An administrative hearing was held in early February 2000 on Monroe's alleged violation of parole conditions: # 1, violation of laws (including the forgery charges); # 3, failure to notify parole officer of change in residency; # 6, operating a motor vehicle while incapacitated by prescription drugs; # 8, failure to report to his parole officer as directed, and failure to attend outpatient treatment as directed; and # 10, failure to follow the special condition that he refrain from consuming intoxicating beverages. At that hearing, probable cause was found that Monroe committed the forgery in violation of condition # 1; that he committed a new DWI charge in violation of condition # 10; and that he committed the assault charge in violation of # 1.
*921 On March 31, 2000, a final parole revocation hearing was held. On April 10, 2000, the Board of Probation and Parole issued an Order of Parole Revocation, which listed the charges that warranted revocation of Monroe's parole as his violation of conditions # 3, # 8, and # 10. The order did not mention the forgery charges (which relates to condition # 1).
In his declaratory judgment petition, Monroe acknowledges that the Board's final revocation order was not based on his violation of condition # 1 (new law violations). The records officer, Ms. Crow, stated: "Your revocation states you were revoked due to # 3, 8, & 10 violations NOT # 1 laws, therefore the cases are not related and Goings does not apply." Monroe's petition specifically asks for a declaration that he is entitled to jail-time credit from the Department of Corrections for all of the time he served while awaiting disposition on the forgery charges.
The Board is entitled to exercise its discretion in determining reasons for revocation. Here, however, Monroe clearly asserts, as to the initial period of incarceration, that after the forgery charge was filed, the jail time was related to the forgery. He asserts that he was then released from custody, and the documentation bears that out. Monroe's pleaded facts and documentation with regard to Monroe's first period of re-incarceration, from November 2, 1999 through December 28, 1999, after his arrest on the forgery charges show: (1) that the original parole violation arrest on November 2, 1999 was based exclusively on the forgery charges; and (2) that Monroe was released December 28, 1999, and subsequently re-arrested on January 3, 2000. Because of the break in Department custody at this point, the Board's stated reasons for revocation in the April 10 Order would presumably not be applicable to the earlier time period. Monroe sufficiently pleads facts showing that the reason for the earlier revocation was his arrest on the forgery charges. For this reason, Monroe has pleaded sufficient facts to state a claim for which relief may be granted, and the petition should not have been dismissed as to this time period. The trial court should grant Monroe an evidentiary hearing on his declaratory judgment petition as to his section 558.031 claim for this earlier time period.
As to the second period of incarceration for parole violation, Monroe's pleaded facts show that the Board expressly revoked his parole from the date of his re-arrest on January 3, 2000, not because of the still pending forgery charges but because of his failure to abide by the following conditions: # 3, failure to report a change of address; # 8, failure to report to the parole officer and obey all directives of the parole officer; and # 10, consumption of intoxicating beverages or entering an establishment where intoxicating beverages are the major item offered for sale. The documentation attached to Monroe's petition and incorporated therein does not contradict the Board's stated reasons for its decision. That documentation shows that at the hearing, Monroe denied guilt of the forgery and stated that his lawyer had a defense to the forgery charges that he could not reveal his defense at that time. The Board might have been reluctant to revoke parole based on the forgery charges, because of the possibility that Monroe would indeed later be able to prove he was not guilty of those charges. The documentation shows that the Board was concerned about violations of other conditions of parole, such as the driving while intoxicated (condition # 10), the failure to attend outpatient treatment (condition # 8), and failure to notify his parole officer of his change of address (condition # 3). There is no indication that Monroe *922 satisfactorily supplied justification for his alleged failures to abide by these conditions.
The Department officer who calculated the jail time credit appropriately took the Board's findings at face value. Based on the Board's decision, this period of incarceration was not "related to" the forgery charges, and Goings and § 558.031 did not apply. Jennifer Crow, the officer calculating jail time credit, could not have found otherwise than that Monroe was not entitled to jail time credit for this second period of incarceration on the parole violations. Monroe has, therefore, failed to plead facts showing that he was entitled to be granted jail-time credit from the Department as to this latter period of incarceration. This portion of his claim must fail.

Conclusion
For the foregoing reasons, the judgment of dismissal is reversed as to the initial period of incarceration (prior to December 28, 1999), and the case is remanded to the trial court for further proceedings in that regard. As to the second period of incarceration, we agree that Monroe's petition, interpreted in light of the attachments which were made a part of the petition, fails to state a claim upon which relief may be granted. Accordingly, the judgment is affirmed in part and reversed in part.
HOLLIGER and SPINDEN, JJ., concur.
NOTES
[1]  While traditionally an action to determine credit for jail time might be brought by a writ application and not by way of a claim for declaratory judgment, the Supreme Court granted relief in Goings v. Mo. Dep't of Corr., 6 S.W.3d 906 (Mo. banc 1999), which was styled a declaratory judgment action. See also Roy v. Mo. Dep't of Corr., 23 S.W.3d 738, 744 (Mo.App.2000).
[2]  Section 558.031.1 states in full:

1. A sentence of imprisonment shall commence when a person convicted of a crime in this state is received into the custody of the department of corrections or other place of confinement where the offender is sentenced. Such person shall receive credit toward the service of a sentence of imprisonment for all time in prison, jail or custody after the offense occurred and before the commencement of the sentence, when the time in custody was related to that offense, except:
(1) Such credit shall only be applied once when sentences are consecutive;
(2) Such credit shall only be applied if the person convicted was in custody in the state of
Missouri, unless such custody was compelled exclusively by the state of Missouri's action;and
(3) As provided in section 559.100, RSMo.
