Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSP does not render Calendar date

843838Mar 19 2007 — edited Mar 20 2007
Hello, I have a problem :) Well, I am working on Struts app that has all its formbeans set as Strings (including date fields). In my actions before setting these date fields, I format the date as follows (and then convert it to a String)

SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
f.setHireDate(dateFormat.format(Calendar.getInstance().getTime()));
f.setHireDate(hireForm.getFutureEmployee().getBirthDate().toString());

Then, on my JSP page I convert this String back to Calendar in the format that I need as follows:

<% pageContext.setAttribute("studentSelectionForm.hireDate", (new java.text.SimpleDateFormat("MM/dd/yyyy")).format((java.util.Calendar.getInstance()).getTime())); %>

<c:choose>
<c:when test="${!empty studentSelectionForm.hireDate}"> <input type="text" name="hireDate" size="12" class="formElement" value="<c:out value='${studentSelectionForm.hireDate}'/>"> </c:when>
otherwise...close choose...

However, my JSP page still shows that date field as a HUGE String like so:

java.util.GregorianCalendar[time=578894400000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/New_York",offset=-18000000,dstSavings=3600000,useDaylight=true,transitions=235,lastRule=java.util.SimpleTimeZone[id=America/New_York,offset=-18000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=2,startDay=8,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=3,endMonth=10,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=1988,MONTH=4,WEEK_OF_YEAR=19,WEEK_OF_MONTH=1,DAY_OF_MONTH=6,DAY_OF_YEAR=127,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=-18000000,DST_OFFSET=3600000]

What am I doing wrong?

Thank you!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2007
Added on Mar 19 2007
2 comments
228 views