Discussion Locked

how do i combine day month and year

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

hi friends,
i'm working on a form that lets the user select a day a month and a year seperately in three combo boxes respectively.How do i combine the three variables to form a date object so that various manipulations could be done with it in java.
the format is as follows
(combobox to select date )(combobox to select month)(combobox to select year)

kindly help

5 replies

by jay eckles

Assuming that the form is being submitted to a JSP or Servlet, then something like the following might be what you're looking for:

Calendar myCal = new Calendar() ;
//using Calendar.set and getTime because Date
//constructor is deprecated
myCal.set( request.getParameter( "year" ), request.getParameter( "month" ), request.getParameter( "date" ) ) ;
Date myDate = myCal.getTime() ;

Jay Eckles

by sheryl v

Which application are you working in? What programming code? If your form is in Microsoft Access, there is a "date serial" function that will translate the 3 separate values into one date for you:
DateSerial (?year?, ?month?, ?day?)

This discussion is closed to new replies.