I have two dates of type String, the first in the format "yyyy.MM.dd" , the second "HH:mm"

They are converted to type Date using SimpleDateFormat ;

So, I need to put them together, that is, the result would be "yyyy.MM.dd HH:mm"

Are there any other options how to fold them, except

 date.setHours(); date.setMinutes(); 
  • one
    Date does not happen "in a format". The format is at the line. Decide what you have and what you need - Anton Shchyrov
  • @Anton Shchyrov, Updated the question. Now I think it will be clear - DevOma
  • Add - is it date1 + date2 or does the string date representation of the date? - Andrew Bystrov
  • Yes, the second, that is, if the first is 2018.02.15, and the second is 22:20, then the result was 2018.02.15 22:20 - DevOma
  • 2
    If you need to concatenate strings, then why translate them into a date? - Anton Shchyrov

2 answers 2

If you just want to concatenate strings, why translate the string into a Date so that you can bring it back to the string again?

Just fold as strings:

 System.out.println(String1 + " " + String2); 

    Does this Class have a factory via String, if so then ....

     Date3.fromString(Date1.toString() + " " + Date2.toString());