I am using following method to convert string to calendar date '2007-05-10T08:10:21-8:00' . The code is as under

public Calendar dateStringCalendar(String s){

    Calendar cal=Calendar.getInstance();
    try{
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        Date d1=df.parse(s);
        cal.setTime(d1);
        return cal;
        }catch(Exception e){

        }
        return cal;
    }

when I get response back to my jsp page it shows me this result

java.util.GregorianCalendar[time=1243436891203,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2009,MONTH=4,WEEK_OF_YEAR=22,WEEK_OF_MONTH=5,DAY_OF_MONTH=27,DAY_OF_YEAR=147,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=8,SECOND=11,MILLISECOND=203,ZONE_OFFSET=0,DST_OFFSET=0]

how can I get human readable format?

Thanks,

b1k1m1

Use get accessor of Calendar class.

Calendar cal=Calendar.getInstance();
out.println(cal.get(cal.DATE) + " " + cal.get(cal.MONTH) + " " + cal.get(cal.YEAR));

Thanks - adatapost for your quick reply.

The problem is I am using this statement in my .java file
String SEntitleEndDate = response.getParameter("EntitleEndDate").toString();
Calendar startthis = dateStringCalendar(SEntitleEndDate); getHardwareResp.setEntitlementEndDate(SEntitleEndDate);

The Response object getHardwareResp.SetEntitlementEndDate only accept Calendar arguments.

So cannot use - cal.get(cal.DATE) + " " + cal.get(cal.MONTH) + " " + cal.get(cal.YEAR));

Thanks,

b1k1m1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.