toLocalDateTime(str: String, format: String | Null = null, locale: String | Null = null): LocalDateTime

Transforms a String value into a LocalDateTime value and accepts a format and locale.

Introduced in DataWeave version 2.4.0.


Name Description


The String value to transform into a LocalDateTime value.


The formatting to use on the LocalDateTime value. A null value has no effect on the LocalDateTime value. This parameter accepts Java character patterns based on ISO-8601. A LocalDateTime value, such as 2011-12-03T10:15:30.000000 has the format uuuu-MM-dd HH:mm:ss.


Optional ISO 3166 country code to use, such as US, AR, or ES. A null or absent value uses your JVM default.


This example shows how toLocalDateTime behaves with different inputs. It produces output in the application/dw format.


%dw 2.0
import * from dw::util::Coercions
output application/dw
  a: toLocalDateTime("2015-10-01T23:57:59"),
  b: toLocalDateTime("2003-10-01 23:57:59","uuuu-MM-dd HH:mm:ss")


  a: |2015-10-01T23:57:59|,
  b: |2003-10-01T23:57:59| as LocalDateTime {format: "uuuu-MM-dd HH:mm:ss"}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub
Submit your feedback!
Share your thoughts to help us build the best documentation experience for you!
Take our latest survey!