Any officer, junior commissioned officer, warrant officer or non-commissioned officer who, having received the pay of a person subject to this Act unlawfully detains or refuses to pay the same when due, shall, on conviction by court- martial, be liable to suffer imprisonment for a term which may extend to ten years or such less punishment as is in this Act mentioned.