Search code examples
javaxtendopenhabjoda-convert

openHAB two Strings to DateTime


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 ?


Solution

  • 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))