I'd like to do this:
Date meetingDateAndTime;
<h:inputText value="Date"/>
<h:inputText value="Time"/>
Once I got only one attribute Date, is it possible to type Date in an inputText and type Time into another and then merge them together?
One of the best ways to Separate a date from a date and time value is by using the INT function. INT function takes an integer from a number and left out the fractional part.
If a cell contains a combined date and time, you can use the INT function to pull the time value into a separate column. Dates are stored as numbers in Excel, with the decimal portion representing the time.
You could use two DateFormats
, one that outputs the Date and one that outputs the Time.
SimpleDateFormat
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
Edit: Sorry, I thought you were trying to write two fields from one date not create one date from two fields. What about the following:
DateFormat dateFormat = new SimpleDateFormt("dd-MM-yyyy hh:mm:ss);
String dateString = dateInputText + " " + timeInputText;
Date date = dateFormat.parse(dateString);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With