That is in time of war and any competent JAG officer should be able to make mincemeat if a charge of desertion in a time of war. We never declared war.
Somehow, I don’t think “enemy” requires a declaration war. I patrolled a border for two years against an enemy against whom there we no declared war or even open hostilities.