comparing Time objects

can anyone.I have included the following code in a servlet. When i run the servlet without thre code it works fine.When i include it it crashes.Both 'depart' and 'pickTime' are java.sql.Time objects.

Thanx.

if(pickTime.compareTo(depart)<=0)

out.println("

<b>bus booked<b>");

else

out.println("

<b>already booked</b>");

}catch(Exception exxx){out.println("xxxx" + exxx.toString());}

[518 byte] By [tmeagh] at [2007-9-26 22:59:28]
# 1

You didn't mention what kind of error you're getting - you just said that the servlet crashes. Check the app server log to see what kind of error you're getting.

I'll take a guess that it's a NullPointerException and further guess that the fix is:

if ( pickTime == null || depart == null) {

// handle this situation somehow

}

else if (pickTime.compareTo(depart)<=0) { ...

eriklindquist at 2007-7-4 3:49:45 > top of Java-index,Archived Forums,New To Java Technology Archive...