Date type Workflow Variable

Problem solved.

I just created a String workflow variable with the format “yyyy-mm-dd”. Since I only require it while using a Java Snippet node, I just use a method to turn it into a Date variable (which serves only the node’s code) each time.

For example:

workflow_var = “2020-12-15”

Then, inside the node’s code:

LocalDate code_var = LocalDate.parse(workflow_var)

or (in case you haven’t explicitly imported the java.time.LocalDate library)

java.time.LocalDate code_var = LocalDate.parse(workflow_var)

In case I need the time, I just take it as 12 PM and replace LocalDate with LocalDateTime:

LocalDateTime code_var = LocalDateTime.parse(workflow_var + “T12:00”)

java.time.LocalDateTime code_var = java.time.LocalDateTime.parse(workflow_var + “T12:00”)

Cheers

2 Likes