openHAB two Strings to DateTime

474 Views Asked by At

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 ?

1

There are 1 best solutions below

0
On BEST ANSWER

I had tried this and it works,

val SimpleDateFormat dateFormatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm" )        
val dateTimeString = dateValue + " " + timeValue
val String dateTimeValue = dateFormatter.format(new Date(dateTimeString))                
val DateTime origStartDate = new DateTime(dateFormatter.parse(dateTimeValue))