How to detect if a workflow is running?

How to detect if a workflow is running in Java, I have the workflowID

What is the use case for this?

I am using signal method - to signal to a workflow that it can complete , I want to detect from my controller if the workflow is completed before showing completed message

In this case I would recommend waiting for the workflow completion using untyped stub and getResult API:

    workflow =  workflowClient.newUntypedWorkflowStub("<workflowId>", "", Optional.of("<workflowType>"));
    String result = workflow.getResult(1000, TimeUnit.SECONDS, String.class);