Formatting date and time
I have a question related to conversion/formatting of date.

I have a date,say,workDate with a value, eg: 2011-11-27 00:00:00 
From an input textbox, I receive a time value(as String) in the form "HH:mm:ss", eg: "06:00:00"

My task is to create a new Date,say,newWorkDate, having the same year,month,date as workDate,and time to be the textbox input value.

So in this case, newWorkDate should be equal to 2011-11-27 06:00:00.
Can you help me figure out how this can be achieved using Java?

Here is what I have so far:

     SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
    //Text box input is converted to Date format -what will be the default year,month and date set here?
     Date textBoxTime = df.parse(minorMandatoryShiftStartTimeStr);
    
     Date workDate = getWorkDate();
     int year = Integer.parseInt(DateHelper.getYYYYMMDD(workDate).substring(0, 4));
     int month = Integer.parseInt(DateHelper.getYYYYMMDD(workDate).substring(4, 6));
     int date = Integer.parseInt(DateHelper.getYYYYMMDD(workDate).substring(6, 8));
            	  
     Date newWorkDate = DateHelper.createDate(year, month, day);
    //not sure how to set the textBox time to this newWorkDate.
Formatting date and time
===

I have a question related to conversion/formatting of date.

I have a date,say,workDate with a value, eg: 2011-11-27 00:00:00 
From an input textbox, I receive a time value(as String) in the form "HH:mm:ss", eg: "06:00:00"

My task is to create a new Date,say,newWorkDate, having the same year,month,date as workDate,and time to be the textbox input value.

So in this case, newWorkDate should be equal to 2011-11-27 06:00:00.
Can you help me figure out how this can be achieved using Java?

Here is what I have so far:

     SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
    //Text box input is converted to Date format -what will be the default year,month and date set here?
     Date textBoxTime = df.parse(minorMandatoryShiftStartTimeStr);
    
     Date workDate = getWorkDate();
     int year = Integer.parseInt(DateHelper.getYYYYMMDD(workDate).substring(0, 4));
     int month = Integer.parseInt(DateHelper.getYYYYMMDD(workDate).substring(4, 6));
     int date = Integer.parseInt(DateHelper.getYYYYMMDD(workDate).substring(6, 8));
            	  
     Date newWorkDate = DateHelper.createDate(year, month, day);
    //not sure how to set the textBox time to this newWorkDate.