I need to produce a timestamp within my workflow corresponding to the current instant in ISO 8601 format:
2025-04-05T11:59:43+00:00
The Camunda 8 implementation of FEEL provides the now() function for this purpose, however based on all of the documentation I can find, it will always be formatted as a zoned date time string:
now()
"2025-04-05T12:08:08.32801833@Etc/UTC"
My aim is to convert the output of now() natively in FEEL to produce a value/string in a format that is in the standard ISO8601 offset-date-time format, and is parseable by the standard java implementation of OffsetDateTime.parse() .
Alternatives I have considered:
Converting the string output of now() manually:
replace(string(now()), "@GMT", "Z")
This is very much a bandaid solution, and will obviously not work if the timezone would change for any reason.
Creating the correctly formatted date-time string in a dedicated job worker - would work but a lot of unnecessary overhead.
I would appreciate any tips on how I could make this conversion work, or if it is not possible in a reasonable way, to extend FEEL to allow for creating now() in different formats.
Hi @matmolni, welcome to the forums! I think I would look at using a DateTimeFormatter and ZonedDateTime when parsing the value in Java, rather than trying to extend the FEEL engine. From there, you can convert it to a LocalDateTime or OffsetDateTime as needed. I think something like this should work:
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class Main {
public static void main(String[] args) {
String datetime = "2025-04-05T12:08:08.32801833@Europe/Berlin";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.nnnnnnnn@VV");
ZonedDateTime zonedDateTime = ZonedDateTime.parse(datetime, formatter);
System.out.println(zonedDateTime);
}
}