Two String variables into DateTime

Hello Community,

Please I need your help, I have two String variables (one has date and other has time),
how can I create DateTime from these two String variables ?
The purpose to use PlusMintues PlusDay …

Can you help me please ?

Did you follow that link I sent you earlier is the previous thread?
Everything you need it there…

How are the two strings formatted?

Yes, I stuck.
Two String such as dateValue = “1/1/2018” and timeValue = “10:40”


A valid time string is like this "“yyyy-MM-dd’T’HH:mm:ss.SSSZ”


val year = dateValue.split("/").get(2)
val month = dateValue.split("/").get(1)
val day = dateValue.split("/").get(0)
val hour = timeValue.split(":").get(0)
val min = timeValue.split(":").get(0)
//Build the string
val dateString = year + "-" + month + "-" + day + "'T'" + hour + ":" + min + ":00.000Z"
val DateTimeType timestamp = DateTimeType.valueOf(dateString)
1 Like

Actually I tried this to create DateTime directly, because I want plusMinutes, …functions